name: Release
on:
push:
tags: ["v*"]
permissions:
contents: write
env:
CARGO_TERM_COLOR: always
jobs:
publish:
runs-on: ubuntu-latest
timeout-minutes: 20
steps:
- uses: actions/checkout@v6
- name: Verify Cargo.toml version matches tag
run: |
TAG="${GITHUB_REF_NAME#v}"
PKG=$(grep -m1 '^version' Cargo.toml | sed 's/.*= *"//; s/".*//')
if [ "$TAG" != "$PKG" ]; then
echo "Tag $GITHUB_REF_NAME (→ $TAG) does not match Cargo.toml $PKG"
exit 1
fi
- name: Test
run: cargo test --all-features
- name: Publish to crates.io
env:
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
run: cargo publish --allow-dirty
- name: Create GitHub Release
uses: softprops/action-gh-release@v3
with:
generate_release_notes: true
prerelease: ${{ contains(github.ref_name, '-alpha') || contains(github.ref_name, '-beta') || contains(github.ref_name, '-rc') }}