name: Release
on:
push:
tags: ['v*']
env:
CARGO_TERM_COLOR: always
jobs:
ci:
name: CI
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
- uses: dtolnay/rust-toolchain@stable
with:
toolchain: "1.91"
components: clippy, rustfmt
- uses: Swatinem/rust-cache@v2
- uses: taiki-e/install-action@nextest
- run: cargo fmt --check
- run: cargo clippy --all-features --tests -- -D warnings
- run: cargo nextest run --all-features
- run: cargo doc --all-features --no-deps
env:
RUSTDOCFLAGS: "-D warnings"
- run: cargo generate-lockfile
- uses: rustsec/audit-check@v2
with:
token: ${{ secrets.GITHUB_TOKEN }}
publish:
name: Publish to crates.io
needs: ci
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
- uses: dtolnay/rust-toolchain@stable
with:
toolchain: "1.91"
- name: Verify tag matches Cargo.toml version
run: |
CARGO_VERSION="v$(grep '^version' Cargo.toml | head -1 | sed 's/.*"\(.*\)"/\1/')"
TAG_VERSION="${GITHUB_REF#refs/tags/}"
if [ "$CARGO_VERSION" != "$TAG_VERSION" ]; then
echo "ERROR: Tag ($TAG_VERSION) does not match Cargo.toml version ($CARGO_VERSION)"
exit 1
fi
echo "Version match: $TAG_VERSION"
- run: cargo publish --all-features
env:
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}