name: Release
on:
push:
tags: ["v*"]
jobs:
publish:
runs-on: macos-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- name: Verify tag matches Cargo.toml version
run: |
CARGO_VER=$(grep '^version' Cargo.toml | head -1 | sed 's/.*"\(.*\)"/\1/')
TAG_VER="${GITHUB_REF_NAME#v}"
echo "Cargo.toml: $CARGO_VER, tag: $TAG_VER"
if [ "$CARGO_VER" != "$TAG_VER" ]; then
echo "ERROR: tag $TAG_VER != Cargo.toml $CARGO_VER"
exit 1
fi
- name: Build and test
run: |
cargo fmt --all -- --check
cargo clippy --workspace -- -W warnings
cargo build --release --workspace
cargo test --workspace
cargo run --example vecadd
cargo run --example matmul
- name: Publish to crates.io
env:
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
run: cargo publish --no-verify
- name: Create GitHub Release
env:
GH_TOKEN: ${{ github.token }}
run: |
gh release create "$GITHUB_REF_NAME" \
--title "$GITHUB_REF_NAME" \
--generate-notes