name: Release
on:
workflow_dispatch:
inputs:
dry_run:
description: 'Dry run (do not actually publish)'
required: false
type: boolean
default: false
env:
CARGO_TERM_COLOR: always
permissions:
contents: write
checks: write
jobs:
release:
name: Release
runs-on: ${{ vars.RUNNER }}
steps:
- name: Checkout repository
uses: actions/checkout@v6
- uses: ubicloud/rust-cache@v2
with:
cache-on-failure: "true"
cache-all-crates: "true"
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
- name: Cache Cargo registry
uses: actions/cache@v5
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.toml') }}
- name: Get current version
id: version
run: |
CURRENT_VERSION=$(cargo metadata --no-deps --format-version 1 | jq -r '.packages[0].version')
echo "current_version=$CURRENT_VERSION" >> $GITHUB_OUTPUT
echo "📦 Publishing version: $CURRENT_VERSION"
- name: Dry run publish
if: ${{ inputs.dry_run }}
run: |
echo "🔍 Dry run mode - no changes will be published"
echo "Would publish version: ${{ steps.version.outputs.current_version }}"
cargo publish --dry-run
- name: Create GitHub Release
if: ${{ !inputs.dry_run }}
uses: softprops/action-gh-release@v2
with:
tag_name: v${{ steps.version.outputs.current_version }}
name: Release release
body: |
See [CHANGELOG.md](./CHANGELOG.md) for detailed changes.
draft: false
prerelease: false
generate_release_notes: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Publish to crates.io
if: ${{ !inputs.dry_run }}
env:
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
run: |
echo "🚀 Publishing version ${{ steps.version.outputs.current_version }}"
cargo publish