From 82b8bb448bca69f92070c27e8c73a6e8455c99b6 Mon Sep 17 00:00:00 2001 From: Rod Vince Date: Thu, 5 Nov 2026 08:03:26 -0600 Subject: [PATCH] ci: the release guard drafts red releases at once, and tells if it fails Two low findings from the independent review of the previous change, and one false sentence. A release whose relevant check had already failed stayed public for the full ten minutes when an unrelated workflow was still running on the tagged commit, because the guard waited for every run before deciding. Once no relevant check is pending and one did not pass, it now drafts without waiting. The draft was the one call left outside any condition: when it failed, bash -e ended the step before the issue was opened and the release stayed public with only a red job as trace. It is now tried three times, and the issue is opened either way, saying so when the release is still public. The issue and the header said drafting takes a version off Packagist. It does not: Packagist reads tags. Measured on milpa/app-runtime v0.175.4, which is drafted and still served by Packagist. Both now say so, and what to do when the version must not be installed. Measured by execution against controlled inputs and mutants, with the current guard as the control (greenhouse evidence/0171). --- .github/workflows/release-guard.yml | 44 ++++++++++++++++++++++++----- 1 file changed, 37 insertions(+), 7 deletions(-) diff --git a/.github/workflows/release-guard.yml b/.github/workflows/release-guard.yml index 65ef5d5..f225958 100644 --- a/.github/workflows/release-guard.yml +++ b/.github/workflows/release-guard.yml @@ -10,8 +10,9 @@ name: Release guard # # IT DRAFTS RATHER THAN DELETES. Deleting is what was done by hand and it worked, but as an # automatism the blast radius is wrong: one false positive destroys a legitimate release and its tag. -# Drafting removes it from the public list and from Packagist, is reversible with one click, and -# leaves the trace of why. A gate you can undo is the only kind you dare install everywhere. +# Drafting removes it from the public list of releases, is reversible with one click, and leaves +# the trace of why. It does not take the version off Packagist, which reads tags, not releases. +# A gate you can undo is the only kind you dare install everywhere. on: release: @@ -34,8 +35,9 @@ jobs: REPO: ${{ github.repository }} run: | set -uo pipefail - # Actions runs this step under `bash -e`. Every call that can fail sits inside a condition, so a - # failed read is handled here instead of ending the step before anyone is told. + # Actions runs this step under `bash -e`. Every read and the draft sit inside a condition, so a + # failed call is handled here instead of ending the step before anyone is told. Only the last + # call, opening the issue, can end the step; the step is red either way. # NO PODER VER NO ES ESTAR VERDE. A commit with no check runs at all is drafted too: a # release published from a tree nobody ever tested is exactly the case this exists for. @@ -85,6 +87,12 @@ jobs: break fi + # Red is red. Once no relevant check is pending and one of them did not pass, the verdict is + # already a draft; waiting for other runs would only keep a red release public longer. + if [ "$seen" = yes ] && [ "$pending" -eq 0 ] && [ "$not_green" -gt 0 ]; then + break + fi + if [ "$waits" -ge "$max_waits" ]; then if [ "$seen" = yes ]; then echo "::warning::Timed out after $((max_waits * wait_seconds)) seconds: $pending relevant check(s) and $running workflow run(s) still going" @@ -117,15 +125,37 @@ jobs: motivo="sin una lectura completa de sus checks en $((max_waits * wait_seconds)) segundos" fi echo "::error::$TAG apunta a un commit que no pasó: $motivo" - gh release edit "$TAG" --repo "$REPO" --draft + + # A failed draft must still reach a person: three tries, and the issue says if all of them failed. + drafted=no + for attempt in 1 2 3; do + if gh release edit "$TAG" --repo "$REPO" --draft; then + drafted=yes + break + fi + if [ "$attempt" -lt 3 ]; then + sleep "$wait_seconds" + fi + done + + if [ "$drafted" = yes ]; then + titulo="Release $TAG pasado a borrador: su commit no está verde" + accion="Se pasó a **borrador** en vez de borrarlo: sale de la lista pública de releases y de \`releases/latest\`, y se deshace con un clic si esto es un falso positivo." + else + echo "::error::No se pudo pasar $TAG a borrador en 3 intentos: sigue publicado" + titulo="Release $TAG sigue publicado: su commit no está verde y no se pudo pasar a borrador" + accion="**No se pudo pasar a borrador** en 3 intentos: sigue publicado. Hay que pasarlo a borrador a mano." + fi cuerpo=$(printf '%s\n' \ "\`$TAG\` apunta a \`${sha:-?}\`, $motivo." \ "" \ - "Se pasó a **borrador** en vez de borrarlo: sale de la lista pública y de Packagist, y se deshace con un clic si esto es un falso positivo." \ + "$accion" \ + "" \ + "El tag sigue existiendo y Packagist lee tags, no releases: la versión se sigue pudiendo instalar. Si no debe instalarse, hay que borrar el tag." \ "" \ "Publicar no pasa por la protección de rama — greenhouse evidence/0171.") gh issue create --repo "$REPO" \ - --title "Release $TAG pasado a borrador: su commit no está verde" \ + --title "$titulo" \ --body "$cuerpo" exit 1