name: Release
on:
workflow_dispatch:
inputs:
version:
description: 'Version to release (e.g., 0.1.0)'
required: true
type: string
env:
RUST_BACKTRACE: 1
CARGO_TERM_COLOR: always
jobs:
validate:
name: Validate Release
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
with:
components: rustfmt, clippy
- name: Verify version matches input
run: |
CARGO_VERSION=$(grep "^version" Cargo.toml | head -1 | cut -d'"' -f2)
if [ "$CARGO_VERSION" != "${{ github.event.inputs.version }}" ]; then
echo "Error: Cargo.toml version ($CARGO_VERSION) does not match input version (${{ github.event.inputs.version }})"
exit 1
fi
echo "Version verified: $CARGO_VERSION"
- name: Check formatting
run: cargo fmt -- --check
- name: Run clippy
run: cargo clippy --all-targets --all-features -- -D warnings
- name: Run all tests
run: cargo test --verbose
- name: Build release
run: cargo build --release --verbose
- name: Verify WASM compatibility
run: |
rustup target add wasm32-unknown-unknown
cargo build --target wasm32-unknown-unknown --release
- name: Check documentation
run: cargo doc --no-deps --all-features
publish:
name: Publish to crates.io
runs-on: ubuntu-latest
needs: validate
steps:
- uses: actions/checkout@v5
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
- name: Publish to crates.io
run: cargo publish --token ${{ secrets.CARGO_REGISTRY_TOKEN }}
env:
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
github-release:
name: Create GitHub Release
runs-on: ubuntu-latest
needs: publish
permissions:
contents: write
steps:
- uses: actions/checkout@v5
- name: Create Release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: v${{ github.event.inputs.version }}
release_name: v${{ github.event.inputs.version }}
body: |
See [CHANGELOG.md](https://github.com/${{ github.repository }}/blob/main/CHANGELOG.md) for details.
draft: false
prerelease: false