name: Release
on:
push:
tags:
- "v*.*.*"
jobs:
publish-crate:
name: Publish to crates.io
runs-on: ubuntu-latest
if: "!contains(github.ref, 'rc') && !contains(github.ref, 'beta')"
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- name: Verify version matches tag
run: |
TAG_VERSION=${GITHUB_REF#refs/tags/v}
CARGO_VERSION=$(grep -m1 '^version' Cargo.toml | cut -d'"' -f2)
if [ "$TAG_VERSION" != "$CARGO_VERSION" ]; then
echo "Error: Tag version ($TAG_VERSION) != Cargo.toml version ($CARGO_VERSION)"
exit 1
fi
- run: cargo publish --token ${{ secrets.CARGO_REGISTRY_TOKEN }}