From 03caf209b3f5c047b54503350851c86a0cfbbf59 Mon Sep 17 00:00:00 2001 From: Antony David Date: Thu, 19 Dec 2024 17:46:09 +0100 Subject: [PATCH] ci: add github release workflow --- .github/workflows/release.yml | 108 ++++++++++++++++++++++++++++++++++ 1 file changed, 108 insertions(+) create mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..ab9c96e --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,108 @@ +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: ubuntu-latest + - os: macos-latest + - os: ubuntu-latest + env: + CARGO_BUILD_TARGET: wasm32-wasi + 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-wasi' + run: | + rustup target add wasm32-wasi + curl -LO https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-20/wasi-sdk_20.0_amd64.deb + sudo dpkg --install wasi-sdk_20.0_amd64.deb + curl https://wasmtime.dev/install.sh -sSf | bash + + - 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 + + - name: Install Rust toolchain + uses: moonrepo/setup-rust@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - name: Publish to crates.io + run: cargo publish + env: + CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }} + + - name: Tag the version + env: + GIT_TAG: ${{ inputs.publish-tag }} + run: | + git tag "${GIT_TAG}" + git push origin "${GIT_TAG}" + + - 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 }}