name: Release
on:
workflow_dispatch:
inputs:
publish-tag:
description: 'The tag of the version to publish'
required: true
type: string
concurrency:
group: release
env:
RUST_BACKTRACE: 1
CARGO_TERM_COLOR: always
jobs:
test-release:
name: Check & Test release
strategy:
fail-fast: false
matrix:
include:
- os: windows-latest
- os: macos-latest
- os: ubuntu-latest
env:
CARGO_BUILD_TARGET: wasm32-wasip1
CARGO_TARGET_WASM32_WASI_RUNNER: /home/runner/.wasmtime/bin/wasmtime --dir=.
runs-on: ${{ matrix.os }}
if: github.ref == 'refs/heads/main'
env: ${{ matrix.env || fromJSON('{}') }}
steps:
- uses: actions/checkout@v4
with:
persist-credentials: false
- name: Install Wasm deps
if: matrix.env.CARGO_BUILD_TARGET == 'wasm32-wasip1'
run: |
rustup target add wasm32-wasip1
curl -LO https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-25/wasi-sdk-25.0-x86_64-linux.deb
sudo dpkg --install wasi-sdk-25.0-x86_64-linux.deb
curl -LO https://github.com/bytecodealliance/wasmtime/releases/download/v43.0.0/wasmtime-v43.0.0-x86_64-linux.tar.xz
tar xvf wasmtime-v43.0.0-x86_64-linux.tar.xz
echo `pwd`/wasmtime-v43.0.0-x86_64-linux >> $GITHUB_PATH
- uses: Swatinem/rust-cache@v2
with:
shared-key: release
save-if: ${{ github.ref_name == 'main' }}
- run: rustup show
- name: Install cargo-hack
uses: taiki-e/install-action@cargo-hack
- name: Clippy
run: cargo hack clippy --feature-powerset -- -D warnings
- name: Test
run: cargo hack test --feature-powerset
- name: Check Documentation
env:
RUSTDOCFLAGS: '-D warnings'
run: cargo hack doc --feature-powerset
- name: Check semver
if: matrix.os == 'ubuntu-latest'
uses: obi1kenobi/cargo-semver-checks-action@v2
publish-release:
name: Publish release
needs: test-release
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/main'
steps:
- name: Checkout
uses: actions/checkout@v4
with:
persist-credentials: true
- uses: taiki-e/install-action@v2.69.8
with:
tool: cargo-edit
- name: Update Cargo.toml version
env:
NEW_VERSION: ${{ inputs.publish-tag }}
run: |
VERSION=${NEW_VERSION#v}
cargo set-version "${VERSION}"
git add Cargo.toml
git commit -m "chore: bump version to ${NEW_VERSION}"
git push
- name: Tag the version
env:
GIT_TAG: ${{ inputs.publish-tag }}
run: |+
git tag "${GIT_TAG}"
git push origin "${GIT_TAG}"
- name: Publish to crates.io
run: cargo publish
env:
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
- name: Create github release
uses: taiki-e/create-gh-release-action@v1
with:
branch: main
ref: refs/tags/"${GIT_TAG}"
env:
GIT_TAG: ${{ inputs.publish-tag }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}