diff --git a/.github/workflows/crates-publish.yml b/.github/workflows/crates-publish.yml index 8425612..d008d64 100644 --- a/.github/workflows/crates-publish.yml +++ b/.github/workflows/crates-publish.yml @@ -11,6 +11,12 @@ name: Crates.io Publish on: release: types: [published] + workflow_dispatch: + inputs: + tag: + description: Release tag to publish (e.g. v1.0.0). Must match Cargo.toml version. + required: true + type: string permissions: id-token: write @@ -20,7 +26,7 @@ jobs: publish: name: cargo publish # Skip prereleases (e.g. v0.1.0-rc.1) — crates.io publishes are permanent. - if: ${{ github.event.release.prerelease == false }} + if: ${{ github.event_name == 'workflow_dispatch' || github.event.release.prerelease == false }} runs-on: ubuntu-latest steps: - name: Checkout @@ -33,7 +39,11 @@ jobs: shell: bash run: | set -euo pipefail - TAG="${{ github.event.release.tag_name }}" + if [ -n "${{ github.event.release.tag_name }}" ]; then + TAG="${{ github.event.release.tag_name }}" + else + TAG="${{ inputs.tag }}" + fi CRATE_VERSION=$(grep -m1 '^version' Cargo.toml | sed 's/.*"\(.*\)".*/\1/') EXPECTED="${TAG#v}" if [ "${CRATE_VERSION}" != "${EXPECTED}" ]; then