name: Release
on:
push:
tags: ["v*"]
jobs:
publish:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- name: Verify tag matches Cargo.toml version
run: |
set -euo pipefail
TAG="${GITHUB_REF#refs/tags/v}"
TAG="${TAG//$'\r'/}"
# Use cargo metadata so we read the real crate version (avoids CRLF / grep hitting the wrong line).
CARGO=$(cargo metadata --no-deps --format-version 1 | jq -r '.packages[] | select(.name == "authforge") | .version')
if [ "$TAG" != "$CARGO" ]; then
echo "Tag v$TAG does not match crate version $CARGO"
exit 1
fi
- name: Test
run: cargo test
- name: Publish to crates.io
env:
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
run: cargo publish