From a478849ef428b283d0350e52cc6584999124dd9a Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 10 Nov 2026 08:27:36 +0000 Subject: [PATCH] release: allow publishing from the Actions tab A manual run tags the commit with the version in Cargo.toml and publishes the release, so a release doesn't need a tag push. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01KLubvhoPRuPfGsAcdikJjN --- .github/workflows/release.yml | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 61ee7fe..dcf1ebf 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -4,6 +4,10 @@ on: push: tags: - 'v*' + # Manual release from the Actions tab: tags the commit it runs on with the + # version in Cargo.toml (e.g. v0.2.0) and publishes it, for when pushing a + # tag yourself isn't convenient. + workflow_dispatch: # Dry run: build and package every target (nothing is published) when the # packaging changes. pull_request: @@ -95,7 +99,7 @@ jobs: release: name: Create Release needs: build - if: startsWith(github.ref, 'refs/tags/') + if: startsWith(github.ref, 'refs/tags/') || github.event_name == 'workflow_dispatch' runs-on: ubuntu-latest permissions: contents: write @@ -106,6 +110,22 @@ jobs: with: path: artifacts + - name: Pick the tag + id: tag + run: | + if [ "$GITHUB_EVENT_NAME" = workflow_dispatch ]; then + version=$(sed -n 's/^version = "\(.*\)"/\1/p' Cargo.toml | head -1) + [ -n "$version" ] || { echo "no version in Cargo.toml" >&2; exit 1; } + tag="v$version" + if git ls-remote --exit-code --tags origin "refs/tags/$tag" >/dev/null; then + echo "$tag already exists; push the tag or bump the version" >&2 + exit 1 + fi + else + tag="$GITHUB_REF_NAME" + fi + echo "tag=$tag" >> "$GITHUB_OUTPUT" + - name: Install cosign uses: sigstore/cosign-installer@v3 @@ -125,6 +145,8 @@ jobs: - name: Create release uses: softprops/action-gh-release@v2 with: + tag_name: ${{ steps.tag.outputs.tag }} + target_commitish: ${{ github.sha }} files: | artifacts/**/*.tar.gz artifacts/**/*.zip