name: Release
on:
workflow_dispatch:
inputs:
level:
description: Version bump level
required: true
default: patch
type: choice
options:
- patch
- minor
- major
concurrency:
group: release
cancel-in-progress: false
env:
CARGO_TERM_COLOR: always
CARGO_TARGET_X86_64_UNKNOWN_LINUX_GNU_RUSTFLAGS: "-C target-cpu=x86-64"
jobs:
ci:
uses: ./.github/workflows/ci.yml
bump_and_tag:
needs: ci
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v5
with:
fetch-depth: 0
- uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@v2
- run: cargo install cargo-release --locked
- run: git config user.email "11601995+ratzrattillo@users.noreply.github.com"
- run: git config user.name "ratzrattillo"
- run: cargo release "${{ inputs.level }}" --execute --no-verify --no-publish --no-push --no-confirm
- uses: ./.github/actions/git-cliff
- run: |
tag="$(git describe --tags --abbrev=0)"
msg="$(git for-each-ref "refs/tags/$tag" --format='%(contents:subject)')"
awk '/^## \[unreleased\]$/{skip=1; next} /^## \[/{skip=0} !skip' CHANGELOG.md > CHANGELOG.tmp
mv CHANGELOG.tmp CHANGELOG.md
git-cliff --latest --prepend CHANGELOG.md
git add CHANGELOG.md
git commit -q --amend --no-edit
git tag -fa "$tag" -m "$msg"
- run: git push origin HEAD "$(git describe --tags --abbrev=0)"
github_release:
needs: bump_and_tag
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v5
with:
fetch-depth: 0
ref: ${{ github.ref_name }}
- run: git fetch --tags origin
- run: gh release create "$(git describe --tags --abbrev=0)" --generate-notes
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
publish:
needs: github_release
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
with:
fetch-depth: 0
ref: ${{ github.ref_name }}
- uses: dtolnay/rust-toolchain@stable
- run: git fetch --tags origin
- run: git checkout "$(git describe --tags --abbrev=0)"
- run: cargo publish --token "${{ secrets.CARGO_REGISTRY_TOKEN }}"