From b4a75f344d46144568cbe56807d2d0e3e3e05b8d Mon Sep 17 00:00:00 2001 From: ZacxDev Date: Thu, 6 Aug 2026 18:49:55 -0500 Subject: [PATCH] ci(release): add workflow_dispatch recovery trigger for a dropped tag-push run MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The 2026-08-06 Actions incident stopped push events from creating workflow runs. #228 added workflow_dispatch to ci.yml for the same reason; release.yml was left with no recovery at all — its only option is deleting and re-pushing a tag users already install from. The dispatch path cannot simply reuse the default checkout: actions/checkout resolves to the default branch on a dispatch, while goreleaser derives the version, changelog and artifact names from the git tag at HEAD. So the trigger takes a `tag` input and checks it out explicitly, and a guard asserts HEAD is exactly that tag before goreleaser runs. The tag-push path is untouched — the diff is 63 insertions and 0 deletions. `ref: ${{ github.event.inputs.tag }}` renders empty on a push, which actions/checkout treats identically to omitting the key, and the guard step is gated on github.event_name == 'workflow_dispatch'. Co-Authored-By: Claude Opus 5 (1M context) --- .github/workflows/release.yml | 69 +++++++++++++++++++++++++++++++++++ 1 file changed, 69 insertions(+) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 4246db54..c7e76ea8 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -4,6 +4,29 @@ on: push: tags: - "v*" + # Manual trigger — the recovery path when GitHub drops a run. + # + # On 2026-08-06 an Actions incident throttled webhook triggers: push and + # pull_request events stopped creating workflow runs entirely. #228 added the + # same escape hatch to ci.yml. Here the stakes are higher: the only recovery + # from a dropped tag-push run today is to DELETE and re-push a tag that users + # already install from. + # + # workflow_dispatch is the only trigger that does not ride a webhook, and it + # cannot be back-applied — a dispatchable workflow must already exist on the + # default branch — so it only ever helps if it lands BEFORE the next + # incident. It will therefore look permanently unused. Do not prune it. + # + # Unlike ci.yml this one needs an input. goreleaser derives the version, + # changelog and artifact names from the git tag at HEAD, and a dispatch + # checks out the DEFAULT BRANCH, where that tag is the wrong one or absent. + # So the tag has to be named explicitly and checked out below. + workflow_dispatch: + inputs: + tag: + description: "Existing tag to release, with the leading v — e.g. v0.1.90. Must already be pushed; this does not create it." + required: true + type: string permissions: contents: write # create the GitHub Release + upload assets @@ -12,10 +35,56 @@ jobs: goreleaser: runs-on: ubuntu-latest steps: + # On a tag push there is no `inputs` in the event payload, so `ref` + # renders as the empty string and checkout falls back to its default + # (github.ref = the pushed tag) — that path is unchanged. On a dispatch + # it resolves the supplied tag to the same detached HEAD at the same + # commit, so goreleaser sees identical git context either way. - uses: actions/checkout@v4 with: + ref: ${{ github.event.inputs.tag }} fetch-depth: 0 # goreleaser needs full history + tags for the changelog + # Dispatch path only — skipped entirely on a tag push. + # + # goreleaser takes the version from the git tag at HEAD, never from + # anything we hand it, so a dispatch that resolves to the wrong ref does + # not fail — it publishes the WRONG release. checkout above already fails + # on a tag that does not exist; this catches the case that would + # otherwise succeed silently, e.g. someone typing a branch name like + # `main`, which is a perfectly valid ref and would release from a branch. + - name: Verify HEAD is exactly the requested tag + if: github.event_name == 'workflow_dispatch' + env: + TAG: ${{ github.event.inputs.tag }} + run: | + set -euo pipefail + if ! git rev-parse -q --verify "refs/tags/${TAG}^{commit}" >/dev/null; then + echo "::error::'${TAG}' is not a tag in this repository. Push the tag first — this workflow releases an existing tag, it does not create one." + exit 1 + fi + head="$(git rev-parse HEAD)" + tagged="$(git rev-parse "refs/tags/${TAG}^{commit}")" + if [ "$head" != "$tagged" ]; then + echo "::error::HEAD is ${head} but tag ${TAG} points at ${tagged}." + exit 1 + fi + # The tag goreleaser will resolve for ITSELF. Mirrors its own lookup + # (internal/pipe/git/git.go, getTag): $GORELEASER_CURRENT_TAG, which + # we do not set, then `git tag --points-at HEAD` under the default + # `-version:refname` sort, then `git describe`. So when two tags sit + # on this commit the highest-sorting one wins and the release would + # go out under THAT name. goreleaser's own validate() does not catch + # this — it only asserts that some tag matching the name it picked is + # at HEAD, never that it matches the tag that was asked for. + at_head="$(git tag --points-at HEAD --sort=-version:refname)" + detected="${at_head%%$'\n'*}" + if [ "$detected" != "$TAG" ]; then + echo "::error::goreleaser would release '${detected}', not '${TAG}'. Refusing rather than publishing the wrong version." + exit 1 + fi + echo "HEAD ${head} is tag ${TAG}; goreleaser will release ${detected}." + - uses: actions/setup-go@v5 with: go-version: "1.25"