From 03caf209b3f5c047b54503350851c86a0cfbbf59 Mon Sep 17 00:00:00 2001 From: Antony David Date: Thu, 19 Dec 2024 17:46:09 +0100 Subject: [PATCH 1/4] 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 }} From 79679c7fd97de88e75a88aac0ee4e14b78ff9d0b Mon Sep 17 00:00:00 2001 From: Antony David Date: Thu, 19 Dec 2024 18:27:15 +0100 Subject: [PATCH 2/4] ci: add cargo.toml version changes --- .github/workflows/release.yml | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index ab9c96e..aa8f9c5 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -23,7 +23,6 @@ jobs: matrix: include: - os: windows-latest - - os: ubuntu-latest - os: macos-latest - os: ubuntu-latest env: @@ -83,6 +82,8 @@ jobs: - name: Install Rust toolchain uses: moonrepo/setup-rust@v1 + with: + bins: cargo-edit env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} @@ -91,6 +92,17 @@ jobs: env: CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }} + - 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 }} From 56f72b898fb294aa7d36f9e0bdf3caccd14e5a78 Mon Sep 17 00:00:00 2001 From: Antony David Date: Thu, 19 Dec 2024 20:56:51 +0100 Subject: [PATCH 3/4] ci: remove setup toolchain --- .github/workflows/release.yml | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index aa8f9c5..7e97e33 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -80,18 +80,15 @@ jobs: with: persist-credentials: true - - name: Install Rust toolchain - uses: moonrepo/setup-rust@v1 - with: - bins: cargo-edit - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - name: Publish to crates.io run: cargo publish env: CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }} + - uses: taiki-e/install-action@v2 + with: + tool: cargo-edit + - name: Update Cargo.toml version env: NEW_VERSION: ${{ inputs.publish-tag }} From dd9cd2501cb45f72aec1ceb4dac7429cc2715550 Mon Sep 17 00:00:00 2001 From: Antony David Date: Thu, 19 Dec 2024 21:18:53 +0100 Subject: [PATCH 4/4] fix: publish after bump of the version --- .github/workflows/release.yml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 7e97e33..b95d15d 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -80,11 +80,6 @@ jobs: with: persist-credentials: true - - name: Publish to crates.io - run: cargo publish - env: - CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }} - - uses: taiki-e/install-action@v2 with: tool: cargo-edit @@ -103,10 +98,15 @@ jobs: - name: Tag the version env: GIT_TAG: ${{ inputs.publish-tag }} - run: | + 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: