Skip to content

Commit e6b069a

Browse files
fix(release): leave the installer values unstamped after publishing the chart
promote-publish-chart.sh stamps platformVersion into packages/core/installer/values.yaml in place and never put it back. On an ephemeral runner that is harmless, but the manual recovery path in docs/release.md runs the script in an operator's own checkout, where it left a modified tracked file that the next commit could pick up and leak onto the release line. The file is now restored from the EXIT trap, so a failing run puts it back as well as a successful one. The publish job runs these scripts from main while holding packages: write on the release registry, which widens what has to be trusted to write stable tags beyond the reviewed release tree. The comment on the checkout now says so next to the correctness cost it already named. The header of the script also records that the already-published probe fails closed on registry answers it does not recognise, so a first-ever push of a new chart repository that GHCR answers with denied or unauthorized aborts and needs one manual helm push. Assisted-by: LLM Signed-off-by: Myasnikov Daniil <[email protected]>
1 parent ad827e3 commit e6b069a

3 files changed

Lines changed: 24 additions & 3 deletions

File tree

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

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -530,9 +530,13 @@ jobs:
530530
# them from the merge commit instead would pin a re-run to the very code
531531
# that failed, which is exactly how v1.6.0 ended up being repaired by hand.
532532
#
533-
# The cost is that a broken promotion script on main breaks the next
533+
# The cost is twofold. A broken promotion script on main breaks the next
534534
# release even when the merge commit carried a good one; hack/*_test.bats
535-
# runs on main under `make unit-tests` to keep that honest.
535+
# runs on main under `make unit-tests` to keep that honest. And trust
536+
# widens: this job holds `packages: write` on the release registry, so the
537+
# code that can write stable tags and the stable chart is no longer the
538+
# reviewed release tree but whatever main holds when the job runs. A change
539+
# to hack/promote-*.sh deserves the review of a release-path change.
536540
- name: Checkout promotion scripts from main
537541
uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4
538542
with:

‎hack/promote-publish-chart.sh‎

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,12 @@
3535
# image tags, that makes re-running the whole registry step after a partial
3636
# failure safe.
3737
#
38+
# The already-published probe fails closed on any registry answer it does not
39+
# recognise. GHCR can answer for a repository that does not exist yet with
40+
# `denied` or `unauthorized` instead of a name-unknown code, so the first-ever
41+
# push of a brand new chart repository may abort here and need one manual
42+
# `helm push`. That is the probe being cautious, not a bug.
43+
#
3844
# Requires: yq (mikefarah), helm, skopeo, and a registry login already done.
3945
set -eu
4046

@@ -75,7 +81,12 @@ mkdir -p "$WORKDIR/fresh" "$WORKDIR/published" "$WORKDIR/fresh-tree" "$WORKDIR/p
7581
# build time, and this env override is what corrects it. Done on the working
7682
# tree only (never committed): committing it would leak platformVersion=vX.Y.Z
7783
# onto main/the release line when the promote PR merges, mis-stamping the next
78-
# rc built from that branch.
84+
# rc built from that branch. The file is put back on exit, because the manual
85+
# recovery path runs this in an operator's own checkout, where a stamped tracked
86+
# file would be left behind.
87+
VALUES_FILE=packages/core/installer/values.yaml
88+
cp "$VALUES_FILE" "$WORKDIR/values.yaml.orig"
89+
trap 'cp "$WORKDIR/values.yaml.orig" "$VALUES_FILE"; rm -rf "$WORKDIR"' EXIT
7990
export STABLE_VERSION
8091
yq -i '.cozystackOperator.platformVersion = "v" + strenv(STABLE_VERSION)' \
8192
packages/core/installer/values.yaml

‎hack/promote-publish-chart_test.bats‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,10 @@ SHIM
144144
# yq keeps the original scalar's quoting style, so the stamped value lands
145145
# double-quoted exactly as it did when this ran inline in the workflow.
146146
grep -q 'platformVersion: "v9.9.9"' "$out/cozy-installer/values.yaml"
147+
148+
# The stamp goes into the package only: a manual recovery runs this in an
149+
# operator's checkout, which must not be left with a modified tracked file.
150+
grep -q 'platformVersion: ""' "$FIX/packages/core/installer/values.yaml"
147151
}
148152

149153
@test "an identical published chart is left alone on a re-run" {
@@ -188,6 +192,8 @@ SHIM
188192
env -u REGISTRY "$ROOT/hack/promote-publish-chart.sh" v9.9.9 >/dev/null 2>&1 || rc=$?
189193
[ "$rc" -eq 1 ]
190194
[ ! -f "$FIXPUSHED" ]
195+
# A failing run puts the tree back too, not only a successful one.
196+
grep -q 'platformVersion: ""' "$FIX/packages/core/installer/values.yaml"
191197

192198
# Break-glass: an operator who has looked at the diff can overwrite.
193199
: >"$FIXLOG_HELM"

0 commit comments

Comments
 (0)