From 7c535319e8dcab7b7e499e3f8878c27676617039 Mon Sep 17 00:00:00 2001 From: Filipe Moreira Date: Mon, 16 Nov 2026 10:03:22 -0300 Subject: [PATCH] ci: a tag pushed by publishing a draft doesn't run the release again Publishing the 1.7.0 draft created its tag, and the tag push started the Release workflow a second time: it rebuilt and replaced the installer and the portable minutes after they were published, rewrote the notes without the Legacy downloads, and winget rejected the submission made from the tested files because the hash no longer matched. A "guard" job now stops a tag-push run when that tag's release is already published. A pushed tag without a release publishes as before. Co-Authored-By: Claude Opus 5.5 --- .github/workflows/release.yml | 32 ++++++++++++++++++++++++++++++-- 1 file changed, 30 insertions(+), 2 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index b8143f4..55d834a 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -16,6 +16,11 @@ name: Release # the same release as ConsoleModeLegacy-*.exe. GitHub lists a release's files by name, so those come after the # current version's; and they don't start like the ones the update check and winget look for, so nobody is # updated to Legacy. +# +# Publishing a draft creates its tag, and that tag push starts this workflow again. The "guard" job stops that +# run: the release is out already, with the files that were tested, and winget.yml sends it to winget. (On 1.7.0 +# the second run rebuilt and replaced the installer and the portable after publishing, dropped the Legacy part +# of the notes, and winget rejected the submission made a moment before for a hash that no longer matched.) on: push: tags: @@ -44,6 +49,29 @@ permissions: actions: read jobs: + # A pushed tag whose release is already published (a draft that was just published) has nothing left to do. + guard: + runs-on: ubuntu-latest + permissions: + contents: read + outputs: + skip: ${{ steps.check.outputs.skip }} + steps: + - name: Is the release already published? + id: check + env: + GH_TOKEN: ${{ github.token }} + EVENT_NAME: ${{ github.event_name }} + TAG: ${{ github.ref_name }} + REPO: ${{ github.repository }} + run: | + skip=false + if [ "$EVENT_NAME" = "push" ] && [ "$(gh release view "$TAG" --repo "$REPO" --json isDraft --jq .isDraft 2>/dev/null)" = "false" ]; then + skip=true + echo "A release $TAG já está publicada (veio de um rascunho): nada a fazer." + fi + echo "skip=$skip" >> "$GITHUB_OUTPUT" + # The Legacy build: the branch's own code, tests and publish script, with the version of this release. legacy: if: github.event_name == 'workflow_dispatch' && github.event.inputs.legacy != '' @@ -103,9 +131,9 @@ jobs: if-no-files-found: error build: - needs: legacy + needs: [guard, legacy] # Without Legacy that job is skipped, and a skipped job would skip this one too. - if: ${{ !cancelled() && (needs.legacy.result == 'success' || needs.legacy.result == 'skipped') }} + if: ${{ !cancelled() && needs.guard.result == 'success' && needs.guard.outputs.skip != 'true' && (needs.legacy.result == 'success' || needs.legacy.result == 'skipped') }} runs-on: windows-latest outputs: version: ${{ steps.version.outputs.version }}