name: Release
on:
workflow_dispatch:
permissions:
contents: write
env:
CARGO_TERM_COLOR: always
jobs:
release:
name: Publish crate and create GitHub release
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install Rust toolchain
run: |
rustup toolchain install stable --profile minimal
rustup default stable
rustup component add rustfmt clippy
- name: Check formatting
run: cargo fmt --all --check
- name: Run clippy
run: cargo clippy --locked --all-targets -- -D warnings
- name: Run tests
run: cargo test --locked --all-targets
- name: Dry-run publish package
run: cargo publish --locked --dry-run
- name: Publish to crates.io
env:
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
run: cargo publish --locked
- name: Read crate version
id: crate
run: |
version="$(cargo metadata --locked --no-deps --format-version 1 | jq -r '.packages[0].version')"
echo "version=$version" >> "$GITHUB_OUTPUT"
- name: Create GitHub release
env:
GH_TOKEN: ${{ github.token }}
run: |
version="${{ steps.crate.outputs.version }}"
gh release create "v${version}" \
--target "${GITHUB_SHA}" \
--title "v${version}" \
--generate-notes