Skip to content

Commit 3c3374c

Browse files
fix(ci): publish the release only after the stable images and chart exist
Finalize undrafted the release before it retagged the images and published the cozy-installer chart, so for the length of the retag the release page announced a version whose images and chart returned manifest unknown. The retag took 80-95 seconds on the 1.6.x patches and several minutes on v1.7.0. A failure in either step also left a public release that a re-run could not repair, because the re-run looked for a draft and found none. Move the draft lookup and the latest decision into their own step that runs before any registry write, hand the decision to the retag, the chart and the release page as step outputs, and undraft last. A missing draft now fails while no stable name exists, and a failed retag leaves the draft in place for a re-run. Assisted-by: LLM Signed-off-by: Myasnikov Daniil <[email protected]>
1 parent 048c029 commit 3c3374c

5 files changed

Lines changed: 212 additions & 84 deletions

File tree

‎.github/workflows/pull-requests-release.yaml‎

Lines changed: 97 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -305,9 +305,12 @@ jobs:
305305
}
306306
}
307307
308-
# Publish draft release and ensure correct latest flag
309-
- name: Publish draft release
310-
id: publish
308+
# Pick the draft this run publishes and decide whether it becomes `latest`,
309+
# before any registry write: a missing draft then fails the job while no
310+
# stable image name exists yet, and the retag, the chart and the release
311+
# page all act on this one decision.
312+
- name: Resolve draft release
313+
id: resolve
311314
uses: actions/github-script@f28e40c7f34bde8b3046d885e986cb6290c5673b # v7
312315
with:
313316
github-token: ${{ steps.app-token.outputs.token }}
@@ -390,10 +393,16 @@ jobs:
390393
const isOutdated = maxRelease && compareSemver(currentSemver, maxRelease.semver) < 0;
391394
const makeLatest = (isRc || isOutdated) ? 'false' : 'true';
392395
393-
// The image retag step below reuses this exact decision to gate
396+
// The retag and chart steps below reuse this exact decision to gate
394397
// whether :latest moves — the release's `latest` and the images'
395398
// :latest must agree (a patch on an old line moves neither).
396399
core.setOutput('make_latest', makeLatest);
400+
core.setOutput('prerelease', String(isRc));
401+
core.setOutput('draft_id', String(draft.id));
402+
if (isOutdated && maxRelease) {
403+
core.setOutput('restore_latest_id', String(maxRelease.id));
404+
core.setOutput('restore_latest_tag', maxRelease.tag);
405+
}
397406
398407
if (isRc) {
399408
console.log(`🏷️ ${tag} is a prerelease, make_latest: false`);
@@ -403,6 +412,84 @@ jobs:
403412
console.log(`🏷️ ${tag} is the highest version, make_latest: true`);
404413
}
405414
415+
# ── Transactional promotion: consumer-visible registry side effects run
416+
# HERE, after the candidate guard passed and the promote PR merged.
417+
# promote-rc.yaml published only a temporary `promotion-*` packages
418+
# candidate, so an abandoned promotion leaves no stable-named bytes.
419+
#
420+
# The checked-out merge commit is the promoted stable tree: the rc's
421+
# digests with the tag string rewritten to stable and the verified
422+
# candidate pinned. skopeo retags those digests to the stable image tag;
423+
# helm packages+pushes the stable chart.
424+
425+
# Retag every rc image/digest plus the verified packages candidate to the
426+
# stable tag. No container rebuild — bit-for-bit
427+
# the e2e-tested rc. :latest moves only when this stable is the newest
428+
# published version, gated by the SAME make_latest decision the release got.
429+
- name: Retag rc images to stable
430+
if: ${{ !contains(steps.get_tag.outputs.tag, '-') }}
431+
env:
432+
STABLE_TAG: ${{ steps.get_tag.outputs.tag }}
433+
MOVE_LATEST: ${{ steps.resolve.outputs.make_latest == 'true' && '1' || '0' }}
434+
run: ./hack/promote-retag.sh "${STABLE_TAG}"
435+
436+
# Publish the stable cozy-installer OCI chart — the documented install path
437+
# (`helm upgrade --install cozystack oci://…/cozy-installer --version X.Y.Z`).
438+
# The retag above covers component images + the cozystack-packages artifact,
439+
# but the chart is a separate OCI artifact referenced in no values.yaml, so
440+
# the stable install 404s (manifest unknown) unless it is published here.
441+
# No container rebuild: the chart is packaged from the merged stable tree,
442+
# which pins the retagged images + artifact by digest; only the chart's
443+
# version and its platformVersion default are stamped.
444+
- name: Publish stable cozy-installer chart
445+
if: ${{ !contains(steps.get_tag.outputs.tag, '-') }}
446+
env:
447+
TAG: ${{ steps.get_tag.outputs.tag }}
448+
MAKE_LATEST: ${{ steps.resolve.outputs.make_latest }}
449+
run: |
450+
set -eu
451+
STABLE_VERSION="${TAG#v}"
452+
# Bake the correct platform version into the chart's DEFAULT values so
453+
# the primary `helm --install --version X.Y.Z` path reports the stable
454+
# version in telemetry — the operator image itself still carries the rc
455+
# version baked at build time, and this env override is what corrects
456+
# it. Done on the working tree only (never committed): committing it
457+
# would leak platformVersion=vX.Y.Z onto main/the release line when the
458+
# promote PR merges, mis-stamping the next rc built from that branch.
459+
export STABLE_VERSION
460+
yq -i '.cozystackOperator.platformVersion = "v" + strenv(STABLE_VERSION)' \
461+
packages/core/installer/values.yaml
462+
PKG="$(helm package packages/core/installer \
463+
--version "${STABLE_VERSION}" --app-version "${STABLE_VERSION}" | awk '{print $NF}')"
464+
helm push "$PKG" "oci://${REGISTRY}"
465+
rm -f "$PKG"
466+
# cozy-installer:latest tracks the newest stable, matching the image
467+
# :latest and the release's `latest` flag — never moved by a patch on
468+
# an older line.
469+
if [ "${MAKE_LATEST}" = "true" ]; then
470+
skopeo copy --multi-arch all \
471+
"docker://${REGISTRY}/cozy-installer:${STABLE_VERSION}" \
472+
"docker://${REGISTRY}/cozy-installer:latest"
473+
fi
474+
475+
# Last on purpose: the release page is what announces this version, so it
476+
# goes public only once the stable images and chart it points at exist. A
477+
# failed retag leaves the draft in place, where a re-run finds it again.
478+
- name: Publish draft release
479+
uses: actions/github-script@f28e40c7f34bde8b3046d885e986cb6290c5673b # v7
480+
env:
481+
PRERELEASE: ${{ steps.resolve.outputs.prerelease }}
482+
MAKE_LATEST: ${{ steps.resolve.outputs.make_latest }}
483+
DRAFT_ID: ${{ steps.resolve.outputs.draft_id }}
484+
RESTORE_LATEST_ID: ${{ steps.resolve.outputs.restore_latest_id }}
485+
RESTORE_LATEST_TAG: ${{ steps.resolve.outputs.restore_latest_tag }}
486+
with:
487+
github-token: ${{ steps.app-token.outputs.token }}
488+
script: |
489+
const tag = '${{ steps.get_tag.outputs.tag }}';
490+
const isRc = process.env.PRERELEASE === 'true';
491+
const makeLatest = process.env.MAKE_LATEST;
492+
406493
// Release body comes from the changelog that merged with THIS PR
407494
// (promote-rc.yaml commits it onto the release-X.Y.Z branch), read
408495
// from the merge commit already checked out here.
@@ -470,7 +557,7 @@ jobs:
470557
await github.rest.repos.updateRelease({
471558
owner: context.repo.owner,
472559
repo: context.repo.repo,
473-
release_id: draft.id,
560+
release_id: Number(process.env.DRAFT_ID),
474561
draft: false,
475562
prerelease: isRc,
476563
make_latest: makeLatest,
@@ -479,73 +566,14 @@ jobs:
479566
console.log(`🚀 Published release ${tag}`);
480567
481568
// If this is a backport/outdated release, ensure the correct release is marked as latest
482-
if (isOutdated && maxRelease) {
483-
console.log(`🔧 Ensuring ${maxRelease.tag} remains the latest release...`);
569+
if (process.env.RESTORE_LATEST_ID) {
570+
const restoreTag = process.env.RESTORE_LATEST_TAG;
571+
console.log(`🔧 Ensuring ${restoreTag} remains the latest release...`);
484572
await github.rest.repos.updateRelease({
485573
owner: context.repo.owner,
486574
repo: context.repo.repo,
487-
release_id: maxRelease.id,
575+
release_id: Number(process.env.RESTORE_LATEST_ID),
488576
make_latest: 'true'
489577
});
490-
console.log(`✅ Restored ${maxRelease.tag} as latest release`);
578+
console.log(`✅ Restored ${restoreTag} as latest release`);
491579
}
492-
493-
# ── Transactional promotion: consumer-visible registry side effects run
494-
# HERE, after the candidate guard passed and the promote PR merged.
495-
# promote-rc.yaml published only a temporary `promotion-*` packages
496-
# candidate, so an abandoned promotion leaves no stable-named bytes.
497-
#
498-
# The checked-out merge commit is the promoted stable tree: the rc's
499-
# digests with the tag string rewritten to stable and the verified
500-
# candidate pinned. skopeo retags those digests to the stable image tag;
501-
# helm packages+pushes the stable chart.
502-
503-
# Retag every rc image/digest plus the verified packages candidate to the
504-
# stable tag. No container rebuild — bit-for-bit
505-
# the e2e-tested rc. :latest moves only when this stable is the newest
506-
# published version, gated by the SAME make_latest decision the release got.
507-
- name: Retag rc images to stable
508-
if: ${{ !contains(steps.get_tag.outputs.tag, '-') }}
509-
env:
510-
STABLE_TAG: ${{ steps.get_tag.outputs.tag }}
511-
MOVE_LATEST: ${{ steps.publish.outputs.make_latest == 'true' && '1' || '0' }}
512-
run: ./hack/promote-retag.sh "${STABLE_TAG}"
513-
514-
# Publish the stable cozy-installer OCI chart — the documented install path
515-
# (`helm upgrade --install cozystack oci://…/cozy-installer --version X.Y.Z`).
516-
# The retag above covers component images + the cozystack-packages artifact,
517-
# but the chart is a separate OCI artifact referenced in no values.yaml, so
518-
# the stable install 404s (manifest unknown) unless it is published here.
519-
# No container rebuild: the chart is packaged from the merged stable tree,
520-
# which pins the retagged images + artifact by digest; only the chart's
521-
# version and its platformVersion default are stamped.
522-
- name: Publish stable cozy-installer chart
523-
if: ${{ !contains(steps.get_tag.outputs.tag, '-') }}
524-
env:
525-
TAG: ${{ steps.get_tag.outputs.tag }}
526-
MAKE_LATEST: ${{ steps.publish.outputs.make_latest }}
527-
run: |
528-
set -eu
529-
STABLE_VERSION="${TAG#v}"
530-
# Bake the correct platform version into the chart's DEFAULT values so
531-
# the primary `helm --install --version X.Y.Z` path reports the stable
532-
# version in telemetry — the operator image itself still carries the rc
533-
# version baked at build time, and this env override is what corrects
534-
# it. Done on the working tree only (never committed): committing it
535-
# would leak platformVersion=vX.Y.Z onto main/the release line when the
536-
# promote PR merges, mis-stamping the next rc built from that branch.
537-
export STABLE_VERSION
538-
yq -i '.cozystackOperator.platformVersion = "v" + strenv(STABLE_VERSION)' \
539-
packages/core/installer/values.yaml
540-
PKG="$(helm package packages/core/installer \
541-
--version "${STABLE_VERSION}" --app-version "${STABLE_VERSION}" | awk '{print $NF}')"
542-
helm push "$PKG" "oci://${REGISTRY}"
543-
rm -f "$PKG"
544-
# cozy-installer:latest tracks the newest stable, matching the image
545-
# :latest and the release's `latest` flag — never moved by a patch on
546-
# an older line.
547-
if [ "${MAKE_LATEST}" = "true" ]; then
548-
skopeo copy --multi-arch all \
549-
"docker://${REGISTRY}/cozy-installer:${STABLE_VERSION}" \
550-
"docker://${REGISTRY}/cozy-installer:latest"
551-
fi

‎docs/agents/releasing.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ The release process is promotion-based — a stable release is a renamed release
2222
1. Cutting a release candidate (`Cut Pre-release Tag` workflow) and watching its mandatory full E2E.
2323
2. Promoting the rc (`Promote RC` workflow), which generates the changelog, opens the parked `cozystack/website` docs PR, and opens the promote PR.
2424
3. Reviewing and merging the promote PR (no squash-merge).
25-
4. Finalize on merge (CI cuts the write-once tag, publishes the release from the merged changelog, and retags the rc images to stable by digest).
25+
4. Finalize on merge (CI cuts the write-once tag, retags the rc images to stable by digest, publishes the stable chart, and last publishes the release from the merged changelog).
2626
5. Merging the parked website docs PR once the release is published.
2727

2828
All detailed steps, workflows, and failure modes are documented in `docs/release.md`.

0 commit comments

Comments
 (0)