mirror of
https://github.com/cozystack/cozystack.git
synced 2026-11-30 04:06:34 +09:00
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. The comments and docs that took the
release to be public by the time finalize pushes the stable tag now say
when it is published.
Deciding latest before the retag opens minutes in which two release PRs
merged close together would both decide they are the newest, leaving
latest on the older line on the page, the image aliases and the chart.
Finalize therefore runs one release at a time, in a concurrency group
that only release PRs join and that queues every merged release rather
than cancelling the one waiting.
The finalize bats suites run both github-script steps under node against
a stubbed API: a missing draft, an orphaned draft, an older patch after
a newer minor, and every shipped changelog's tag. A contract test fails
on a registry step allowed to fail, a publish step that runs after a
failure, a `latest` that moves without the decision, or finalize runs
that may overlap.
Assisted-by: LLM
Signed-off-by: Myasnikov Daniil <myasnikovdaniil2001@gmail.com>
(cherry picked from commit e1472e58de)
This commit is contained in:
7 files changed
+325
-97
No files matched your search
@@ -598,9 +598,9 @@ jobs:
|
||||
#
|
||||
# Previously this lived in tags.yaml::generate-changelog, gated on the stable
|
||||
# tag push. Under the promote flow that tag is created by
|
||||
# pull-requests-release.yaml finalize — i.e. AFTER the release is published —
|
||||
# so the changelog PR could only ever be opened once the release was already
|
||||
# public. Moving generation here is the only fix; re-gating the tag-triggered
|
||||
# pull-requests-release.yaml finalize, in the run that publishes the release
|
||||
# once the retag and the chart are done, so the changelog PR could never be
|
||||
# reviewed before the release went public. Moving generation here is the only fix; re-gating the tag-triggered
|
||||
# job cannot help.
|
||||
#
|
||||
# The generation logic is factored into .github/workflows/changelog-generate.yaml
|
||||
|
||||
@@ -46,6 +46,19 @@ jobs:
|
||||
contains(github.event.pull_request.labels.*.name, 'release') &&
|
||||
github.event.pull_request.user.login == 'cozystack-ci[bot]'
|
||||
|
||||
# One finalize at a time across release PRs. Each decides `latest` from the
|
||||
# releases already published, then moves it on the release page, the image
|
||||
# :latest aliases and cozy-installer:latest minutes later, so two
|
||||
# overlapping runs could both decide they are the newest and leave `latest`
|
||||
# on the older line. The group repeats the `if:` above so a PR that skips
|
||||
# finalize never joins it, and `queue: max` lets every merged release wait
|
||||
# its turn: by default GitHub keeps one pending job per group and cancels
|
||||
# the older one when a third arrives.
|
||||
concurrency:
|
||||
group: ${{ (github.event.pull_request.merged == true && contains(github.event.pull_request.labels.*.name, 'release') && github.event.pull_request.user.login == 'cozystack-ci[bot]') && 'release-finalize' || format('release-finalize-skipped-{0}', github.event.pull_request.number) }}
|
||||
cancel-in-progress: false
|
||||
queue: max
|
||||
|
||||
env:
|
||||
# The registry promotion writes to: component images and the cozy-installer
|
||||
# chart. GHCR — the release registry tags.yaml builds rc images into — NOT
|
||||
@@ -305,9 +318,12 @@ jobs:
|
||||
}
|
||||
}
|
||||
|
||||
# Publish draft release and ensure correct latest flag
|
||||
- name: Publish draft release
|
||||
id: publish
|
||||
# Pick the draft this run publishes and decide whether it becomes `latest`,
|
||||
# before any registry write: a missing draft then fails the job while no
|
||||
# stable image name exists yet, and the retag, the chart and the release
|
||||
# page all act on this one decision.
|
||||
- name: Resolve draft release
|
||||
id: resolve
|
||||
uses: actions/github-script@f28e40c7f34bde8b3046d885e986cb6290c5673b # v7
|
||||
with:
|
||||
github-token: ${{ steps.app-token.outputs.token }}
|
||||
@@ -390,10 +406,16 @@ jobs:
|
||||
const isOutdated = maxRelease && compareSemver(currentSemver, maxRelease.semver) < 0;
|
||||
const makeLatest = (isRc || isOutdated) ? 'false' : 'true';
|
||||
|
||||
// The image retag step below reuses this exact decision to gate
|
||||
// The retag and chart steps below reuse this exact decision to gate
|
||||
// whether :latest moves — the release's `latest` and the images'
|
||||
// :latest must agree (a patch on an old line moves neither).
|
||||
core.setOutput('make_latest', makeLatest);
|
||||
core.setOutput('prerelease', String(isRc));
|
||||
core.setOutput('draft_id', String(draft.id));
|
||||
if (isOutdated && maxRelease) {
|
||||
core.setOutput('restore_latest_id', String(maxRelease.id));
|
||||
core.setOutput('restore_latest_tag', maxRelease.tag);
|
||||
}
|
||||
|
||||
if (isRc) {
|
||||
console.log(`🏷️ ${tag} is a prerelease, make_latest: false`);
|
||||
@@ -403,6 +425,84 @@ jobs:
|
||||
console.log(`🏷️ ${tag} is the highest version, make_latest: true`);
|
||||
}
|
||||
|
||||
# ── Transactional promotion: consumer-visible registry side effects run
|
||||
# HERE, after the candidate guard passed and the promote PR merged.
|
||||
# promote-rc.yaml published only a temporary `promotion-*` packages
|
||||
# candidate, so an abandoned promotion leaves no stable-named bytes.
|
||||
#
|
||||
# The checked-out merge commit is the promoted stable tree: the rc's
|
||||
# digests with the tag string rewritten to stable and the verified
|
||||
# candidate pinned. skopeo retags those digests to the stable image tag;
|
||||
# helm packages+pushes the stable chart.
|
||||
|
||||
# Retag every rc image/digest plus the verified packages candidate to the
|
||||
# stable tag. No container rebuild — bit-for-bit
|
||||
# the e2e-tested rc. :latest moves only when this stable is the newest
|
||||
# published version, gated by the SAME make_latest decision the release got.
|
||||
- name: Retag rc images to stable
|
||||
if: ${{ !contains(steps.get_tag.outputs.tag, '-') }}
|
||||
env:
|
||||
STABLE_TAG: ${{ steps.get_tag.outputs.tag }}
|
||||
MOVE_LATEST: ${{ steps.resolve.outputs.make_latest == 'true' && '1' || '0' }}
|
||||
run: ./hack/promote-retag.sh "${STABLE_TAG}"
|
||||
|
||||
# Publish the stable cozy-installer OCI chart — the documented install path
|
||||
# (`helm upgrade --install cozystack oci://…/cozy-installer --version X.Y.Z`).
|
||||
# The retag above covers component images + the cozystack-packages artifact,
|
||||
# but the chart is a separate OCI artifact referenced in no values.yaml, so
|
||||
# the stable install 404s (manifest unknown) unless it is published here.
|
||||
# No container rebuild: the chart is packaged from the merged stable tree,
|
||||
# which pins the retagged images + artifact by digest; only the chart's
|
||||
# version and its platformVersion default are stamped.
|
||||
- name: Publish stable cozy-installer chart
|
||||
if: ${{ !contains(steps.get_tag.outputs.tag, '-') }}
|
||||
env:
|
||||
TAG: ${{ steps.get_tag.outputs.tag }}
|
||||
MAKE_LATEST: ${{ steps.resolve.outputs.make_latest }}
|
||||
run: |
|
||||
set -eu
|
||||
STABLE_VERSION="${TAG#v}"
|
||||
# Bake the correct platform version into the chart's DEFAULT values so
|
||||
# the primary `helm --install --version X.Y.Z` path reports the stable
|
||||
# version in telemetry — the operator image itself still carries the rc
|
||||
# version baked at build time, and this env override is what corrects
|
||||
# it. Done on the working tree only (never committed): committing it
|
||||
# would leak platformVersion=vX.Y.Z onto main/the release line when the
|
||||
# promote PR merges, mis-stamping the next rc built from that branch.
|
||||
export STABLE_VERSION
|
||||
yq -i '.cozystackOperator.platformVersion = "v" + strenv(STABLE_VERSION)' \
|
||||
packages/core/installer/values.yaml
|
||||
PKG="$(helm package packages/core/installer \
|
||||
--version "${STABLE_VERSION}" --app-version "${STABLE_VERSION}" | awk '{print $NF}')"
|
||||
helm push "$PKG" "oci://${REGISTRY}"
|
||||
rm -f "$PKG"
|
||||
# cozy-installer:latest tracks the newest stable, matching the image
|
||||
# :latest and the release's `latest` flag — never moved by a patch on
|
||||
# an older line.
|
||||
if [ "${MAKE_LATEST}" = "true" ]; then
|
||||
skopeo copy --multi-arch all \
|
||||
"docker://${REGISTRY}/cozy-installer:${STABLE_VERSION}" \
|
||||
"docker://${REGISTRY}/cozy-installer:latest"
|
||||
fi
|
||||
|
||||
# Last on purpose: the release page is what announces this version, so it
|
||||
# goes public only once the stable images and chart it points at exist. A
|
||||
# failed retag leaves the draft in place, where a re-run finds it again.
|
||||
- name: Publish draft release
|
||||
uses: actions/github-script@f28e40c7f34bde8b3046d885e986cb6290c5673b # v7
|
||||
env:
|
||||
PRERELEASE: ${{ steps.resolve.outputs.prerelease }}
|
||||
MAKE_LATEST: ${{ steps.resolve.outputs.make_latest }}
|
||||
DRAFT_ID: ${{ steps.resolve.outputs.draft_id }}
|
||||
RESTORE_LATEST_ID: ${{ steps.resolve.outputs.restore_latest_id }}
|
||||
RESTORE_LATEST_TAG: ${{ steps.resolve.outputs.restore_latest_tag }}
|
||||
with:
|
||||
github-token: ${{ steps.app-token.outputs.token }}
|
||||
script: |
|
||||
const tag = '${{ steps.get_tag.outputs.tag }}';
|
||||
const isRc = process.env.PRERELEASE === 'true';
|
||||
const makeLatest = process.env.MAKE_LATEST;
|
||||
|
||||
// Release body comes from the changelog that merged with THIS PR
|
||||
// (promote-rc.yaml commits it onto the release-X.Y.Z branch), read
|
||||
// from the merge commit already checked out here.
|
||||
@@ -470,7 +570,7 @@ jobs:
|
||||
await github.rest.repos.updateRelease({
|
||||
owner: context.repo.owner,
|
||||
repo: context.repo.repo,
|
||||
release_id: draft.id,
|
||||
release_id: Number(process.env.DRAFT_ID),
|
||||
draft: false,
|
||||
prerelease: isRc,
|
||||
make_latest: makeLatest,
|
||||
@@ -479,73 +579,14 @@ jobs:
|
||||
console.log(`🚀 Published release ${tag}`);
|
||||
|
||||
// If this is a backport/outdated release, ensure the correct release is marked as latest
|
||||
if (isOutdated && maxRelease) {
|
||||
console.log(`🔧 Ensuring ${maxRelease.tag} remains the latest release...`);
|
||||
if (process.env.RESTORE_LATEST_ID) {
|
||||
const restoreTag = process.env.RESTORE_LATEST_TAG;
|
||||
console.log(`🔧 Ensuring ${restoreTag} remains the latest release...`);
|
||||
await github.rest.repos.updateRelease({
|
||||
owner: context.repo.owner,
|
||||
repo: context.repo.repo,
|
||||
release_id: maxRelease.id,
|
||||
release_id: Number(process.env.RESTORE_LATEST_ID),
|
||||
make_latest: 'true'
|
||||
});
|
||||
console.log(`✅ Restored ${maxRelease.tag} as latest release`);
|
||||
console.log(`✅ Restored ${restoreTag} as latest release`);
|
||||
}
|
||||
|
||||
# ── Transactional promotion: consumer-visible registry side effects run
|
||||
# HERE, after the candidate guard passed and the promote PR merged.
|
||||
# promote-rc.yaml published only a temporary `promotion-*` packages
|
||||
# candidate, so an abandoned promotion leaves no stable-named bytes.
|
||||
#
|
||||
# The checked-out merge commit is the promoted stable tree: the rc's
|
||||
# digests with the tag string rewritten to stable and the verified
|
||||
# candidate pinned. skopeo retags those digests to the stable image tag;
|
||||
# helm packages+pushes the stable chart.
|
||||
|
||||
# Retag every rc image/digest plus the verified packages candidate to the
|
||||
# stable tag. No container rebuild — bit-for-bit
|
||||
# the e2e-tested rc. :latest moves only when this stable is the newest
|
||||
# published version, gated by the SAME make_latest decision the release got.
|
||||
- name: Retag rc images to stable
|
||||
if: ${{ !contains(steps.get_tag.outputs.tag, '-') }}
|
||||
env:
|
||||
STABLE_TAG: ${{ steps.get_tag.outputs.tag }}
|
||||
MOVE_LATEST: ${{ steps.publish.outputs.make_latest == 'true' && '1' || '0' }}
|
||||
run: ./hack/promote-retag.sh "${STABLE_TAG}"
|
||||
|
||||
# Publish the stable cozy-installer OCI chart — the documented install path
|
||||
# (`helm upgrade --install cozystack oci://…/cozy-installer --version X.Y.Z`).
|
||||
# The retag above covers component images + the cozystack-packages artifact,
|
||||
# but the chart is a separate OCI artifact referenced in no values.yaml, so
|
||||
# the stable install 404s (manifest unknown) unless it is published here.
|
||||
# No container rebuild: the chart is packaged from the merged stable tree,
|
||||
# which pins the retagged images + artifact by digest; only the chart's
|
||||
# version and its platformVersion default are stamped.
|
||||
- name: Publish stable cozy-installer chart
|
||||
if: ${{ !contains(steps.get_tag.outputs.tag, '-') }}
|
||||
env:
|
||||
TAG: ${{ steps.get_tag.outputs.tag }}
|
||||
MAKE_LATEST: ${{ steps.publish.outputs.make_latest }}
|
||||
run: |
|
||||
set -eu
|
||||
STABLE_VERSION="${TAG#v}"
|
||||
# Bake the correct platform version into the chart's DEFAULT values so
|
||||
# the primary `helm --install --version X.Y.Z` path reports the stable
|
||||
# version in telemetry — the operator image itself still carries the rc
|
||||
# version baked at build time, and this env override is what corrects
|
||||
# it. Done on the working tree only (never committed): committing it
|
||||
# would leak platformVersion=vX.Y.Z onto main/the release line when the
|
||||
# promote PR merges, mis-stamping the next rc built from that branch.
|
||||
export STABLE_VERSION
|
||||
yq -i '.cozystackOperator.platformVersion = "v" + strenv(STABLE_VERSION)' \
|
||||
packages/core/installer/values.yaml
|
||||
PKG="$(helm package packages/core/installer \
|
||||
--version "${STABLE_VERSION}" --app-version "${STABLE_VERSION}" | awk '{print $NF}')"
|
||||
helm push "$PKG" "oci://${REGISTRY}"
|
||||
rm -f "$PKG"
|
||||
# cozy-installer:latest tracks the newest stable, matching the image
|
||||
# :latest and the release's `latest` flag — never moved by a patch on
|
||||
# an older line.
|
||||
if [ "${MAKE_LATEST}" = "true" ]; then
|
||||
skopeo copy --multi-arch all \
|
||||
"docker://${REGISTRY}/cozy-installer:${STABLE_VERSION}" \
|
||||
"docker://${REGISTRY}/cozy-installer:latest"
|
||||
fi
|
||||
@@ -635,8 +635,8 @@ jobs:
|
||||
# release-X.Y.Z branch so it rides the promote PR and is on the base branch the
|
||||
# moment finalize publishes the release. That is the whole point of
|
||||
# generating it there: at the time THIS job runs the stable tag has already been
|
||||
# pushed by finalize, which means the release is already public — too late for a
|
||||
# changelog PR to be of any use to a reader.
|
||||
# pushed by finalize, whose run publishes the release once the retag and the chart
|
||||
# are done — too late for a changelog PR to be of any use to a reader.
|
||||
#
|
||||
# What the freeze changed: promote-rc.yaml bases its promote PR on release-X.Y
|
||||
# whenever that branch exists, and cutting vX.Y.0-rc.1 now creates it. So EVERY
|
||||
@@ -669,8 +669,8 @@ jobs:
|
||||
# !cancelled(): this job runs on stable tags only, which skip build-arm64,
|
||||
# and a skipped ancestor makes the implicit success() false.
|
||||
if: ${{ !cancelled() && needs.prepare-release.result == 'success' && !contains(github.ref_name, '-') }}
|
||||
# Non-blocking: this is a best-effort backfill of an already-published
|
||||
# release, never a gate on one.
|
||||
# Non-blocking: this is a best-effort backfill for the release finalize
|
||||
# publishes, never a gate on one.
|
||||
continue-on-error: true
|
||||
steps:
|
||||
- name: Generate GitHub App token
|
||||
@@ -737,8 +737,8 @@ jobs:
|
||||
# promote flow it normally is, because the promote PR carried it onto
|
||||
# release-X.Y and the stable tag sits on that merge commit. Since the freeze
|
||||
# that PR always targets the line, so this is the usual state on arrival:
|
||||
# `exists` false, `at_tag` true, a reviewed and already-published changelog
|
||||
# sitting right here — port it rather than regenerate.
|
||||
# `exists` false, `at_tag` true, the reviewed changelog finalize publishes as
|
||||
# the release body sitting right here — port it rather than regenerate.
|
||||
#
|
||||
# Only when both are false is there genuinely no changelog to publish, and
|
||||
# only then does the AI run.
|
||||
@@ -761,7 +761,7 @@ jobs:
|
||||
# it reaches the tag via the merge commit. That PR targets the maintenance
|
||||
# line for every release since the freeze, so the file lands on
|
||||
# release-X.Y and never reaches main — `exists` above is false even though
|
||||
# a reviewed, already-PUBLISHED changelog exists right here.
|
||||
# the reviewed changelog finalize publishes as the body exists right here.
|
||||
#
|
||||
# Regenerating in that case would spend a second AI run and, once the
|
||||
# backstop PR merged, update-releasenotes.yaml would overwrite the
|
||||
@@ -808,7 +808,7 @@ jobs:
|
||||
CHANGELOG_BRANCH="changelog-v${VERSION}"
|
||||
|
||||
# Two ways the file can be here: ported verbatim from the tag commit
|
||||
# (at_tag=true — the reviewed, already-published changelog reaching main
|
||||
# (at_tag=true — the reviewed changelog finalize publishes, reaching main
|
||||
# for the first time), or freshly generated above. Either is valid.
|
||||
if [ ! -f "$CHANGELOG_FILE" ]; then
|
||||
echo "::error::Changelog file $CHANGELOG_FILE is absent — it was neither present at the tag nor produced by the Generate changelog using AI step"
|
||||
|
||||
Reference in new issue
Block a user