name: release
on:
workflow_dispatch:
inputs:
bump:
description: Version bump type
required: true
type: choice
options: [patch, minor, major]
env:
CARGO_TERM_COLOR: always
jobs:
gate:
uses: ./.github/workflows/rust.yml
release:
needs: gate
runs-on: ubuntu-latest
permissions:
contents: write
id-token: write
steps:
- uses: actions/checkout@v4
- uses: Swatinem/rust-cache@v2
- name: Install cargo-edit
run: cargo install cargo-edit --locked
- name: Bump version
id: version
run: |
cargo set-version --bump ${{ inputs.bump }}
VERSION=$(cargo pkgid | sed 's/.*#//')
echo "version=${VERSION}" >> "$GITHUB_OUTPUT"
- name: Commit and tag
env:
VERSION: ${{ steps.version.outputs.version }}
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add Cargo.toml Cargo.lock
git commit -m "v${VERSION}"
git tag -a "v${VERSION}" -m "v${VERSION}"
- name: Authenticate with crates.io
uses: rust-lang/crates-io-auth-action@v1
id: auth
- name: Publish
run: cargo publish
env:
CARGO_REGISTRY_TOKEN: ${{ steps.auth.outputs.token }}
- name: Push
run: git push --follow-tags
- name: Create GitHub release
env:
GH_TOKEN: ${{ github.token }}
run: gh release create "v${{ steps.version.outputs.version }}" --generate-notes