name: Release
# Publishes to crates.io and cuts a GitHub release when a v* tag is pushed.
# Requires the CARGO_REGISTRY_TOKEN repo secret (Settings → Secrets and
# variables → Actions). The tag should match the Cargo.toml version (vX.Y.Z).
on:
push:
tags:
env:
CARGO_TERM_COLOR: always
permissions:
contents: write # create the GitHub release
jobs:
publish:
name: publish to crates.io + GitHub release
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@v2
- name: gate before publishing
run: |
cargo fmt --all -- --check
cargo clippy --all-targets --all-features -- -D warnings
cargo test --all-features
- name: publish to crates.io
run: cargo publish --token ${{ secrets.CARGO_REGISTRY_TOKEN }}
- name: GitHub release
uses: softprops/action-gh-release@v2
with:
generate_release_notes: true