Skip to content

Release

Release #67

Workflow file for this run

name: Release
on:
workflow_dispatch:
inputs:
prerelease:
description: |
The semantic version pre-release string.
E.g. in `v1.2.3-beta.2` the pre-release string is `beta.3`.
required: false
push:
tags:
- "*"
defaults:
run:
shell: bash
jobs:
setup:
name: Get release parameters
outputs:
SEMANTIC_VERSION: ${{ steps.params.outputs.SEMANTIC_VERSION }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
fetch-tags: true
- name: Get release parameters
id: params
run: |
# Get the release version:
IDL2JSON_CARGO_VERSION="$(cargo metadata --locked | jq -r '.packages[] | select(.name == "idl2json") | .version')"
PRERELEASE="${{ github.event.inputs.prerelease }}"
SEMANTIC_VERSION="${IDL2JSON_CARGO_VERSION}${PRERELEASE:+-}${PRERELEASE}"
GIT_TAG="v$SEMANTIC_VERSION"
(
for var in IDL2JSON_CARGO_VERSION PRERELEASE SEMANTIC_VERSION GIT_TAG ; do
echo "$var=${!var}"
done
) | tee -a $GITHUB_OUTPUT
- name: Tag this commit
run: |
# Tag this commit, if it not already tagged. Also, verifty that the tag isn't on a different commit.
if COMMIT="$(git show-ref "refs/tags/$GIT_TAG")" ; then
if [[ "$GIT_TAG" == "$GITHUB_SHA" ]]
then echo "Tag $GIT_TAG already exists on this commit."
else echo "::error::Tag $GIT_TAG already exists and points to a different commit."
exit 1
fi
else
echo "Tagging commit $GITHUB_SHA with $GIT_TAG..."
git tag "$GIT_TAG"
git push origin "refs/tags/$GIT_TAG"
fi
- name: Create a draft release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ steps.params.outputs.GIT_TAG }}
release_name: Release ${{ steps.params.outputs.SEMANTIC_VERSION }}
draft: true
prerelease: ${{ steps.params.outputs.PRERELEASE }}
build:
name: Release binary for ${{ matrix.name }}
needs: setup
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-latest
name: linux
target_dir: target/x86_64-unknown-linux-musl/release/
asset_name: idl2json_cli-x86_64-unknown-linux-musl.tar.gz
old_name: idl2json-linux-x86_64.tar.gz
make_target: musl-static
build: musl
pack: tar
# - os: windows-latest
# name: windows
# target_dir: target/release/
# asset_name: idl2json-windows-x86_64
# make_target: release
# rust: 1.60.0
- os: macos-latest
name: macos
target_dir: target/release/
asset_name: idl2json_cli-x86_64-apple-darwin.zip
old_name: idl2json-macos-x86_64.zip
make_target: release
rust: 1.60.0
build: cargo
pack: zip
# - os: ubuntu-latest
# name: arm
# target_file: target/arm-unknown-linux-gnueabihf/release/{idl2json,yaml2candid}
# asset_name: idl2json-arm_32
# make_target: unused
# rust: 1.60.0
steps:
- name: Stop, we are just testing
run: |
echo SEMANTIC_VERSION="${{ needs.setup.outputs.SEMANTIC_VERSION }}"
false
- uses: actions/checkout@v4
# BUILD
- name: Static build with musl
if: matrix.build == 'musl'
uses: mariodfinity/rust-musl-action@master
with:
args: make ${{ matrix.make_target }}
- name: Install toolchain (ARM)
if: matrix.name == 'arm'
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: ${{ matrix.rust }}
override: true
target: arm-unknown-linux-gnueabihf
- name: Build with cargo
if: matrix.build == 'cargo'
run: make ${{ matrix.make_target }}
- name: Cross build
if: matrix.name == 'arm'
uses: actions-rs/cargo@v1
with:
use-cross: true
command: build
args: --target arm-unknown-linux-gnueabihf --features static-ssl --release --locked
# ZIP
- name: tar the results
if: matrix.pack == 'tar'
run: |
tar -C "${{ matrix.target_dir }}" -czvf "$PWD/${{ matrix.asset_name }}" idl2json yaml2candid
- name: zip the results
if: matrix.pack == 'zip'
run: |
zipfile="$PWD/${{ matrix.asset_name }}"
cd "${{ matrix.target_dir }}"
zip "$zipfile" idl2json yaml2candid
- name: Support the old download location
run: cp "${{ matrix.asset_name }}" "${{ matrix.old_name }}"
# UPLOAD
- name: Upload binaries to release
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: "${{ matrix.asset_name }}"
tag: "${{ github.ref }}"
publish_idl2json:
needs: build
name: Publish idl2json to crates.io
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
include:
- package: idl2json
steps:
- uses: actions/checkout@v4
- name: Publish ${{ matrix.package }}
env:
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
run: cargo publish -p "${{ matrix.package }}"
publish_idl2json_cli:
needs: publish_idl2json
name: Publish idl2json_cli to crates.io
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
include:
- package: idl2json_cli
steps:
- uses: actions/checkout@v4
- name: Publish ${{ matrix.package }}
env:
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
run: cargo publish -p "${{ matrix.package }}"