name: Release
on:
release:
types: [published]
permissions:
contents: read
concurrency:
group: release-${{ github.event.release.tag_name }}
cancel-in-progress: false
env:
CARGO_TERM_COLOR: always
jobs:
release:
name: Verify and publish crate
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- name: Check out release tag
uses: actions/checkout@v7.0.1
with:
ref: ${{ github.event.release.tag_name }}
persist-credentials: false
- name: Install stable Rust
uses: dtolnay/rust-toolchain@stable
with:
components: clippy, rustfmt
- name: Validate release metadata
env:
RELEASE_TAG: ${{ github.event.release.tag_name }}
run: |
version="$(cargo metadata --locked --no-deps --format-version 1 | jq -r '.packages[0].version')"
test "$RELEASE_TAG" = "v$version"
awk -v prefix="## [$version] - " 'index($0, prefix) == 1 && substr($0, length(prefix) + 1) ~ /^[0-9]{4}-[0-9]{2}-[0-9]{2}$/ { found = 1 } END { exit !found }' CHANGELOG.md
- name: Check formatting
run: cargo fmt --all -- --check
- name: Lint all targets and features
run: cargo clippy --locked --all-targets --all-features -- -D warnings
- name: Test default features
run: cargo test --locked
- name: Test all features
run: cargo test --all-features --locked
- name: Check examples
run: cargo check --examples --locked
- name: Build documentation
run: cargo doc --all-features --no-deps --locked
env:
RUSTDOCFLAGS: -D warnings
- name: Verify crate package
run: cargo package --locked
- name: Check publication
run: cargo publish --dry-run --locked
- name: Publish to crates.io
run: cargo publish --locked
env:
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}