name: Bump version
on:
workflow_dispatch:
inputs:
bump:
description: Semantic version component to increment
required: true
default: patch
type: choice
options:
- patch
- minor
- major
permissions:
contents: write
concurrency:
group: release-version
cancel-in-progress: false
jobs:
bump:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
ref: main
fetch-depth: 0
- uses: dtolnay/rust-toolchain@stable
with:
components: clippy, rustfmt
- uses: Swatinem/rust-cache@v2
- name: Install cargo-edit
run: cargo install cargo-edit --locked
- name: Update version
run: cargo set-version --bump "${{ inputs.bump }}"
- name: Read version
id: version
run: echo "version=$(cargo metadata --no-deps --format-version 1 | jq -r '.packages[0].version')" >> "$GITHUB_OUTPUT"
- name: Check tag availability
run: git rev-parse "v${{ steps.version.outputs.version }}" >/dev/null 2>&1 && exit 1 || exit 0
- run: cargo fmt --all --check
- run: cargo clippy --all-targets --all-features -- -D warnings
- run: cargo test --all-features --locked
- run: cargo publish --dry-run --locked
- name: Commit and tag
env:
VERSION: ${{ steps.version.outputs.version }}
run: |
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git add Cargo.toml Cargo.lock
git commit -m "release: v${VERSION}"
git tag -a "v${VERSION}" -m "v${VERSION}"
git push --atomic origin HEAD:main "v${VERSION}"