name: Release
on:
push:
tags:
- "v[0-9]+.*"
permissions:
contents: read
env:
CARGO_TERM_COLOR: always
RUST_BACKTRACE: 1
CARGO_NET_RETRY: 10
RUSTUP_MAX_RETRIES: 10
CARGO_INCREMENTAL: 0
jobs:
verify:
name: Verify Tag
runs-on: ubuntu-latest
permissions:
contents: read
outputs:
version: ${{ steps.extract.outputs.version }}
steps:
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 with:
persist-credentials: false
- name: Extract and verify version
id: extract
run: |
TAG_VERSION="${GITHUB_REF_NAME#v}"
CARGO_VERSION=$(sed -n 's/^version = "\(.*\)"/\1/p' Cargo.toml | head -1)
echo "Tag version: $TAG_VERSION"
echo "Cargo.toml version: $CARGO_VERSION"
if [ "$TAG_VERSION" != "$CARGO_VERSION" ]; then
echo "::error::Tag version ($TAG_VERSION) does not match Cargo.toml version ($CARGO_VERSION)"
exit 1
fi
echo "version=$TAG_VERSION" >> "$GITHUB_OUTPUT"
test:
name: Test
needs: [verify]
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 with:
persist-credentials: false
- uses: dtolnay/rust-toolchain@631a55b12751854ce901bb631d5902ceb48146f7 with:
components: rustfmt, clippy
- run: cargo fmt --check
- run: cargo clippy --all-targets -- -W clippy::all -W clippy::pedantic -D warnings
- name: Install nextest
uses: taiki-e/install-action@70e00552f3196d9a4c7dde7c57ef4c4830d422dd with:
tool: cargo-nextest
- run: cargo nextest run
publish:
name: Publish to crates.io
needs: [verify, test]
runs-on: ubuntu-latest
environment: crates-io
permissions:
contents: read
id-token: write
steps:
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 with:
persist-credentials: false
- uses: dtolnay/rust-toolchain@631a55b12751854ce901bb631d5902ceb48146f7
- name: Authenticate with crates.io
uses: rust-lang/crates-io-auth-action@b7e9a28eded4986ec6b1fa40eeee8f8f165559ec id: auth
- name: Publish
run: cargo publish
env:
CARGO_REGISTRY_TOKEN: ${{ steps.auth.outputs.token }}
github-release:
name: GitHub Release
needs: [verify, publish]
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 with:
fetch-depth: 0
persist-credentials: false
- name: Install git-cliff
uses: taiki-e/install-action@70e00552f3196d9a4c7dde7c57ef4c4830d422dd with:
tool: git-cliff
- name: Generate release notes
run: git cliff --latest --strip header --output RELEASE_NOTES.md
- name: Create GitHub Release
uses: softprops/action-gh-release@a06a81a03ee405af7f2048a818ed3f03bbf83c7b with:
body_path: RELEASE_NOTES.md
generate_release_notes: false