Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: add github release workflow #76

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
117 changes: 117 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
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
Jayllyz marked this conversation as resolved.
Show resolved Hide resolved
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

- uses: taiki-e/install-action@v2
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}"
Jayllyz marked this conversation as resolved.
Show resolved Hide resolved
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 }}