Skip to content

Commit 9f5550a

Browse files
fix(release): publish rewritten packages during RC promotion (#3795)
## What this PR does Fixes #3477. - Publishes a new packages OCI candidate after rewriting RC image tags to stable tags. - Pins the candidate digest in the stable installer without rebuilding container images. - Verifies the candidate against the prospective merge and original RC artifact before creating stable names. - Refuses promotion when the target maintenance branch lacks the candidate-aware pipeline. - Protects candidates referenced by open release PRs from retention cleanup. - Leaves already published v1.6.0 and v1.6.1 unchanged. ### Screenshots Not applicable. ### Downstream repositories - [x] No downstream repository is affected by this change - [ ] [cozystack/website](https://github.com/cozystack/website) - follow-up: - [ ] [cozystack/terraform-provider-cozystack](https://github.com/cozystack/terraform-provider-cozystack) - follow-up: - [ ] [cozystack/ansible-cozystack](https://github.com/cozystack/ansible-cozystack) - follow-up: - [ ] [cozystack/ccp](https://github.com/cozystack/ccp) - follow-up: - [ ] [cozystack/talm](https://github.com/cozystack/talm) - follow-up: - [ ] [cozystack/cozyhr](https://github.com/cozystack/cozyhr) - follow-up: - [ ] [cozystack/cozy-proxy](https://github.com/cozystack/cozy-proxy) - follow-up: - [ ] [cozystack/cozystack-telemetry-server](https://github.com/cozystack/cozystack-telemetry-server) - follow-up: - [ ] [cozystack/external-apps-example](https://github.com/cozystack/external-apps-example) - follow-up: - [ ] [cozystack/examples](https://github.com/cozystack/examples) - follow-up: ### Testing - `bats --no-tempdir-cleanup hack/promote-packages-artifact_test.bats hack/verify-promoted-packages_test.bats hack/promote-packages-contract.bats hack/promotion-retention-contract.bats` - `actionlint .github/workflows/promote-rc.yaml .github/workflows/pull-requests.yaml .github/workflows/pull-requests-release.yaml .github/workflows/retention.yaml` - `sh -n hack/promote-packages-artifact.sh hack/verify-promoted-packages.sh` - `git diff --check origin/main...HEAD` ### Release note ```release-note fix(release): publish the rewritten stable packages artifact when promoting a release candidate ``` <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **New Features** - Release candidates now use temporary, immutable package artifacts verified before stable publication. - Stable promotions validate package contents, installer references, container digests, and release metadata before tagging. - Temporary promotion artifacts are retained while needed and cleaned up after expiration. - **Bug Fixes** - Improved handling of release labels, fork pull requests, and promotion pull requests. - Added end-to-end verification before release promotion. - Prevented invalid, ambiguous, or untrusted package references from being promoted. - **Documentation** - Updated release and promotion guidance for candidate verification, digest pinning, and transactional promotion. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
2 parents eebe586 + 27ccb50 commit 9f5550a

17 files changed

Lines changed: 2018 additions & 166 deletions

‎.github/workflows/e2e-fork.yaml‎

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,9 @@ on:
3535
#
3636
# A triggering run that concluded `cancelled` or `skipped` gets a group of its
3737
# OWN, keyed by that run's id. Such a run built nothing — labelling an open fork
38-
# PR produces one, because `plan` in pull-requests.yaml discards every label
39-
# other than full-e2e and every job skips — and `resolve` recognises it and
40-
# posts no status at all. In the shared group it would still cancel the live
38+
# PR produces one, because `plan` in pull-requests.yaml discards every label a
39+
# fork run could not publish for and every job skips — and `resolve` recognises
40+
# it and posts no status at all. In the shared group it would still cancel the live
4141
# privileged run that DOES own the status for that head SHA, and the pair
4242
# "cancel the owner, then post nothing" leaves the SHA at "Expected" with
4343
# nothing left to flip it: the run that replaced the owner is the very one that
@@ -142,8 +142,16 @@ jobs:
142142
}
143143
144144
// Discarded label event: pull-requests.yaml triggers on `labeled` but
145-
// its `plan` guard discards every label other than full-e2e, so such a
146-
// run skips every job and builds nothing. Post NOTHING and stop —
145+
// its `plan` guard discards every label a fork run could not publish
146+
// for, so such a run skips every job and builds nothing. That guard
147+
// admits full-e2e, and admits `release` for SAME-REPO PRs only —
148+
// deliberately, for this check. A `release`-labelled run reaches
149+
// `plan` but has `build`/`finalize` gated off by its own label, so it
150+
// succeeds having produced no pr-patch, and this lane would take it
151+
// for a real run and fail closed below on the missing artifact. The
152+
// same shape still reaches here from a PUSH to a fork PR somebody
153+
// mislabelled `release`; that predates promotion using the label and
154+
// is not fixed here. Post NOTHING and stop —
147155
// deciding here would overwrite an already-green status with red (via
148156
// the CONCLUSION check or the missing-pr-patch check below) every time
149157
// anyone labels an open fork PR. Fail-closed: statuses are per-SHA and

‎.github/workflows/promote-rc.yaml‎

Lines changed: 165 additions & 36 deletions
Large diffs are not rendered by default.

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

Lines changed: 88 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,82 @@ jobs:
9292
# app token authenticates, matching how promote-rc.yaml already pushes.
9393
persist-credentials: false
9494

95+
# Use the trusted pre-merge base version of the verifier, while its root
96+
# argument remains the merged packages tree checked out above. This keeps
97+
# the final guard independent of the release PR's executable contents.
98+
- name: Checkout release tooling from base
99+
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
100+
with:
101+
ref: ${{ github.event.pull_request.base.sha }}
102+
path: .release-tooling
103+
sparse-checkout: hack
104+
persist-credentials: false
105+
106+
# Resolve and verify the candidate before creating any write-once stable
107+
# git or registry name. The candidate was serialized at promote time from
108+
# the tag-rewritten tree; this guard pulls it by the committed digest and
109+
# proves it still matches the merge commit (apart from its impossible
110+
# self-reference) and still pins the rc-tested container digests.
111+
#
112+
# flux and yq are version-pinned: they are what this job verifies the
113+
# candidate with and what stamps the stable chart, so `latest/download`
114+
# would make an irreversible step depend on whatever mikefarah shipped
115+
# this morning. The version tracks
116+
# packages/core/testing/images/e2e-sandbox/Dockerfile. yq is additionally
117+
# pinned by content — it stamps the chart's platformVersion, and this step
118+
# is the last one before write-once names exist. The Flux installer is not,
119+
# because it checksums the binary it fetches and the mutable part is its
120+
# own bootstrap script. promote-rc.yaml's copy carries the full reasoning.
121+
- name: Set up promotion toolchain (flux, skopeo, yq, helm)
122+
if: ${{ !contains(steps.get_tag.outputs.tag, '-') }}
123+
env:
124+
FLUX_VERSION: "2.8.6"
125+
YQ_VERSION: "4.53.3"
126+
YQ_SHA256: "fa52a4e758c63d38299163fbdd1edfb4c4963247918bf9c1c5d31d84789eded4"
127+
run: |
128+
if ! flux version --client 2>/dev/null | grep -qx "flux: v${FLUX_VERSION}"; then
129+
install_script="$(mktemp)"
130+
curl -fsSL https://fluxcd.io/install.sh -o "$install_script"
131+
sudo env "FLUX_VERSION=$FLUX_VERSION" bash "$install_script"
132+
rm -f "$install_script"
133+
fi
134+
if ! yq --version 2>/dev/null | grep -q "mikefarah.* version v${YQ_VERSION}\$"; then
135+
yq_bin="$(mktemp)"
136+
curl -fsSL -o "$yq_bin" \
137+
"https://github.com/mikefarah/yq/releases/download/v${YQ_VERSION}/yq_linux_amd64"
138+
printf '%s %s\n' "$YQ_SHA256" "$yq_bin" | sha256sum -c -
139+
sudo install -m 0755 "$yq_bin" /usr/local/bin/yq
140+
rm -f "$yq_bin"
141+
fi
142+
command -v skopeo >/dev/null \
143+
|| { sudo apt-get update -qq && sudo apt-get install -y -qq skopeo; }
144+
command -v helm >/dev/null \
145+
|| curl -fsSL https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3 | bash
146+
# Not installed here, only required: `flux pull artifact` reads its
147+
# registry credentials from ~/.docker/config.json, which is why the
148+
# login step below runs `docker login` as well as skopeo's and helm's.
149+
# This job's runner class is not one of the docker-using build ones, so
150+
# say what is missing here rather than letting the login step fail with
151+
# a bare "command not found" in the middle of the release path.
152+
command -v docker >/dev/null \
153+
|| { echo "::error::docker is required on this runner: flux reads registry credentials from ~/.docker/config.json"; exit 1; }
154+
155+
- name: Login to registry (GHCR)
156+
if: ${{ !contains(steps.get_tag.outputs.tag, '-') }}
157+
env:
158+
GHCR_USER: ${{ github.actor }}
159+
GHCR_TOKEN: ${{ secrets.GITHUB_TOKEN }}
160+
run: |
161+
echo "$GHCR_TOKEN" | docker login "${REGISTRY%%/*}" -u "$GHCR_USER" --password-stdin
162+
echo "$GHCR_TOKEN" | skopeo login "${REGISTRY%%/*}" -u "$GHCR_USER" --password-stdin
163+
echo "$GHCR_TOKEN" | helm registry login "${REGISTRY%%/*}" -u "$GHCR_USER" --password-stdin
164+
165+
- name: Verify stable packages candidate
166+
if: ${{ !contains(steps.get_tag.outputs.tag, '-') }}
167+
env:
168+
TAG: ${{ steps.get_tag.outputs.tag }}
169+
run: .release-tooling/hack/verify-promoted-packages.sh "${TAG#v}"
170+
95171
# Create the release tag at the merge commit — write-once.
96172
#
97173
# The tag is attached to the PR merge commit, which did not exist before
@@ -389,34 +465,18 @@ jobs:
389465
console.log(`✅ Restored ${maxRelease.tag} as latest release`);
390466
}
391467
392-
# ── Transactional promotion: the registry side effects run HERE, after the
393-
# stable tag is cut and the release is published — i.e. after the promote
394-
# PR's e2e passed and the PR merged. promote-rc.yaml did none of this at
395-
# dispatch time, so an abandoned promotion left no stable-named bytes.
468+
# ── Transactional promotion: consumer-visible registry side effects run
469+
# HERE, after the candidate guard passed and the promote PR merged.
470+
# promote-rc.yaml published only a temporary `promotion-*` packages
471+
# candidate, so an abandoned promotion leaves no stable-named bytes.
396472
#
397473
# The checked-out merge commit is the promoted stable tree: the rc's
398-
# digests with the tag string rewritten to stable. skopeo retags those
399-
# digests to the stable image tag; helm packages+pushes the stable chart.
400-
- name: Set up toolchain (skopeo, yq, helm)
401-
if: ${{ !contains(steps.get_tag.outputs.tag, '-') }}
402-
run: |
403-
command -v yq >/dev/null \
404-
|| { sudo curl -sSL -o /usr/local/bin/yq https://github.com/mikefarah/yq/releases/latest/download/yq_linux_amd64 && sudo chmod +x /usr/local/bin/yq; }
405-
command -v skopeo >/dev/null \
406-
|| { sudo apt-get update -qq && sudo apt-get install -y -qq skopeo; }
407-
command -v helm >/dev/null \
408-
|| curl -fsSL https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3 | bash
409-
410-
- name: Login to registry (GHCR)
411-
if: ${{ !contains(steps.get_tag.outputs.tag, '-') }}
412-
env:
413-
GHCR_USER: ${{ github.actor }}
414-
GHCR_TOKEN: ${{ secrets.GITHUB_TOKEN }}
415-
run: |
416-
echo "$GHCR_TOKEN" | skopeo login "${REGISTRY%%/*}" -u "$GHCR_USER" --password-stdin
417-
echo "$GHCR_TOKEN" | helm registry login "${REGISTRY%%/*}" -u "$GHCR_USER" --password-stdin
474+
# digests with the tag string rewritten to stable and the verified
475+
# candidate pinned. skopeo retags those digests to the stable image tag;
476+
# helm packages+pushes the stable chart.
418477

419-
# Retag every rc image/digest to the stable tag. No rebuild — bit-for-bit
478+
# Retag every rc image/digest plus the verified packages candidate to the
479+
# stable tag. No container rebuild — bit-for-bit
420480
# the e2e-tested rc. :latest moves only when this stable is the newest
421481
# published version, gated by the SAME make_latest decision the release got.
422482
- name: Retag rc images to stable
@@ -431,9 +491,9 @@ jobs:
431491
# The retag above covers component images + the cozystack-packages artifact,
432492
# but the chart is a separate OCI artifact referenced in no values.yaml, so
433493
# the stable install 404s (manifest unknown) unless it is published here.
434-
# No rebuild: the chart is packaged from the merged stable tree, which pins
435-
# the retagged images + artifact by digest; only the chart's version and
436-
# its platformVersion default are stamped.
494+
# No container rebuild: the chart is packaged from the merged stable tree,
495+
# which pins the retagged images + artifact by digest; only the chart's
496+
# version and its platformVersion default are stamped.
437497
- name: Publish stable cozy-installer chart
438498
if: ${{ !contains(steps.get_tag.outputs.tag, '-') }}
439499
env:

0 commit comments

Comments
 (0)