Free, Open Source, Self-Hosted WhatsApp API Gateway
TypeScript apibotgatewayself-hostedwhatsappwhatsapp-apiwhatsapp-automationwhatsapp-botwhatsapp-gatewaywhatsapp-gateway-apiwhatsapp-webwhatsapp-web-api
fix(release): keep the staging version once promote has run
Yudhi Armyndharisb370e403aa4a
diff --git a/.github/workflows/release.yml b/.github/workflows/release.ymlindex 3830b1a5c..61759f676 100644--- a/.github/workflows/release.yml+++ b/.github/workflows/release.yml@@ -823,8 +823,9 @@ jobs:# the staging tag would otherwise leak. On the happy path the release tags share the staging# version, so the step below does not run at all (the deliberate retention documented above): the# package-versions API is eventually consistent, and a read that does not list the new release- # tags yet would count the staging tag alone and delete the version just published. On a failed- # run the staging tag is alone and gets removed.+ # tags yet would count the staging tag alone and delete the version just published. The same+ # holds for a promote that failed after re-pointing some tags, so the step runs only when promote+ # never ran, which is the one case where the staging tag is alone and gets removed.cleanup-staging:name: Clean up the staging tagruns-on: ubuntu-latest@@ -835,10 +836,10 @@ jobs:needs: [docker, boot-smoke, image-scan, promote]steps:- name: Remove the staging tag (only when it is alone on its version)- # Never after a successful promote: the release tags share this version by construction, so- # a tag count of 1 there can only be a stale read. The count below still guards a promote- # that failed after attaching some release tags.- if: needs.promote.result != 'success'+ # Only when promote never ran: once it has started re-pointing tags, the version can carry+ # release tags that a stale read does not list yet. A failed or cancelled promote leaves the+ # stray staging tag behind, the same retention as the happy path.+ if: needs.promote.result == 'skipped'# Best-effort: a failed tidy-up must not turn an otherwise successful release red.continue-on-error: trueenv:diff --git a/src/common/release-staging-cleanup.spec.ts b/src/common/release-staging-cleanup.spec.tsindex 24599b73a..2dc43cbe8 100644--- a/src/common/release-staging-cleanup.spec.ts+++ b/src/common/release-staging-cleanup.spec.ts@@ -6,8 +6,9 @@ import * as yaml from 'js-yaml';* GHCR deletes by version, and after a successful promote the release tags share the staging tag's* version. The cleanup job decides from a read of the package-versions API, which is eventually* consistent: a read that does not list the new release tags yet shows the staging tag alone, and- * deleting that version unpublishes X.Y.Z, X.Y and latest together. So the delete step must not- * run at all once promote succeeded, whatever the read says.+ * deleting that version unpublishes X.Y.Z, X.Y and latest together. A promote that failed partway+ * may already have attached release tags too, and the same read cannot be trusted there. So the+ * delete step runs only when promote never ran, whatever the read says.*/describe('release staging-tag cleanup', () => {type Step = { if?: string; run?: string };@@ -22,10 +23,10 @@ describe('release staging-tag cleanup', () => {expect(job?.needs).toContain('promote');});- it('skips every delete once promote succeeded', () => {+ it('skips every delete once promote ran at all', () => {const deleting = (job?.steps ?? []).filter(step => /-X DELETE/.test(step.run ?? ''));// Vacuity guard: a renamed job or a reworded command would leave nothing to check.expect(deleting.length).toBeGreaterThan(0);- for (const step of deleting) expect(step.if).toBe("needs.promote.result != 'success'");+ for (const step of deleting) expect(step.if).toBe("needs.promote.result == 'skipped'");});});