Skip to content

Commit 53a7fc4

Browse files
feat(release): cutting an rc freezes the line into release-X.Y
Cutting the first vX.Y.0-rc.N now creates release-X.Y at the tagged commit, and every later cut for that line must be dispatched from the branch — a dispatch from main is refused. Before this, only the stable promote-PR merge created release-X.Y, so rc.2 and rc.3 were cut from main's tip and silently picked up every feature merged since rc.1. The release therefore shipped content no rc had ever validated. Freezing at the rc closes that: main stays open for the next minor, and fixes reach the release by cherry-pick onto the branch. promote-rc.yaml needs no change — it already prefers release-X.Y as the promote PR base when that branch exists, so the stable release is now cut from the frozen tree. Gated to -rc (alpha/beta are pre-freeze builds off an open main) and to patch 0 (a patch-line rc is cut from a release-X.Y that already exists). The branch is create-only and never force-moved: moving it would re-open the freeze and drag in whatever the new tip holds. Assisted-By: Claude <[email protected]> Signed-off-by: Myasnikov Daniil <[email protected]>
1 parent 3f967ec commit 53a7fc4

1 file changed

Lines changed: 74 additions & 0 deletions

File tree

‎.github/workflows/cut-prerelease.yaml‎

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,13 @@ name: Cut Pre-release Tag
1212
# pre-release (vX.Y.0-rc.N), or `release-X.Y` for a patch line (vX.Y.Z-rc.N).
1313
# The workflow tags that branch's HEAD.
1414
#
15+
# Cutting the first vX.Y.0-rc.N ALSO freezes the line: it creates `release-X.Y`
16+
# at the tagged commit, and every later cut for that line must come from the
17+
# branch (a dispatch from `main` is refused). That is what stops features
18+
# merged after the rc from silently shipping in the release — before this, rc.2
19+
# was cut from main's tip and picked up everything that had landed meanwhile.
20+
# `main` stays open for the next minor; fixes reach the release by cherry-pick.
21+
#
1522
# Why a workflow instead of a manual `git push`:
1623
# 1. The tag is pushed with the CI app token. A tag pushed with the default
1724
# GITHUB_TOKEN would NOT trigger tags.yaml (GitHub suppresses workflow
@@ -78,6 +85,7 @@ jobs:
7885
core.setOutput('tag', tag);
7986
core.setOutput('line', `${m[1]}.${m[2]}`); // 1.6
8087
core.setOutput('patch', m[3]); // 0
88+
core.setOutput('kind', m[4]); // rc
8189
8290
# Refuse to cut from anything but main or the *matching* release-X.Y line.
8391
# The pushed tag's base_ref (= the dispatch branch) must be one tags.yaml
@@ -163,6 +171,35 @@ jobs:
163171
fetch-depth: 1
164172
token: ${{ steps.app-token.outputs.token }}
165173

174+
# Enforce the freeze. Once release-X.Y exists, that line's content is
175+
# closed and lives only on the branch. A vX.Y.* pre-release dispatched
176+
# from 'main' after the freeze would tag main's tip, picking up every
177+
# feature merged since — exactly what the release branch exists to
178+
# prevent. Applies to alpha/beta too: after the freeze the whole line
179+
# comes off the branch, whatever the pre-release kind.
180+
#
181+
# Runs BEFORE the tag push so a mistaken dispatch fails without burning
182+
# the write-once tag name.
183+
- name: Refuse to cut a frozen line from main
184+
if: github.ref_name == 'main'
185+
env:
186+
LINE: ${{ steps.parse.outputs.line }}
187+
run: |
188+
# Distinguish "absent" (--exit-code exits 2) from a transport/auth
189+
# failure, mirroring the write-once query below: an infra blip must
190+
# not read as "not frozen, go ahead".
191+
set +e
192+
git ls-remote --exit-code --heads origin "refs/heads/release-$LINE" >/dev/null 2>&1
193+
rc=$?
194+
set -e
195+
if [ "$rc" -eq 0 ]; then
196+
echo "::error::release-$LINE already exists — the $LINE line is frozen. Cut v$LINE.* from 'release-$LINE' (cherry-pick fixes there first); 'main' is open for the next minor."
197+
exit 1
198+
elif [ "$rc" -ne 2 ]; then
199+
echo "::error::Could not query origin for release-$LINE (git ls-remote exit $rc) — refusing to proceed."
200+
exit 1
201+
fi
202+
166203
- name: Cut and push the pre-release tag
167204
env:
168205
TAG: ${{ steps.parse.outputs.tag }}
@@ -222,3 +259,40 @@ jobs:
222259
git push origin "HEAD:refs/tags/$TAG"
223260
echo "Pushed $TAG at $local_head from '$REF_NAME'."
224261
echo "tags.yaml will now build and draft the pre-release and create its staging branch; rc tags also run mandatory full E2E."
262+
263+
# Freeze the line. An rc is the feature-freeze signal, so the first
264+
# vX.Y.0-rc.N branches release-X.Y at the tagged commit. From here the
265+
# release's content is closed: fixes reach it only by cherry-pick or
266+
# backport onto the branch, while 'main' moves on to the next minor.
267+
# promote-rc.yaml then targets its promote PR at release-X.Y (it already
268+
# prefers that branch when it exists), so the stable release is cut from
269+
# the frozen tree rather than from whatever main has accumulated.
270+
#
271+
# Gated to -rc: alpha/beta are pre-freeze validation builds cut from an
272+
# open main, and freezing on them would force every later change onto
273+
# cherry-picks far too early.
274+
#
275+
# Gated to patch 0: a patch-line rc (vX.Y.Z-rc.N, Z>0) is cut from
276+
# release-X.Y, which by definition already exists.
277+
#
278+
# Create-only, never force-moved — a later rc.N finds the branch and
279+
# no-ops. Moving it would silently re-open the freeze and drag in
280+
# whatever the new tip contains, defeating the whole mechanism.
281+
- name: Freeze the line (create release-X.Y)
282+
if: steps.parse.outputs.kind == 'rc' && steps.parse.outputs.patch == '0'
283+
env:
284+
LINE: ${{ steps.parse.outputs.line }}
285+
TAG: ${{ steps.parse.outputs.tag }}
286+
run: |
287+
BRANCH="release-$LINE"
288+
EXISTING="$(git ls-remote --heads origin "refs/heads/$BRANCH" | cut -f1)"
289+
if [ -n "$EXISTING" ]; then
290+
echo "✅ $BRANCH already exists at $EXISTING; leaving it untouched."
291+
exit 0
292+
fi
293+
# HEAD is the commit just tagged: the stale-tip guard above proved it
294+
# still equals the remote branch tip, so branch and tag agree.
295+
git push origin "HEAD:refs/heads/$BRANCH"
296+
echo "🔒 Froze the $LINE line: created $BRANCH at $(git rev-parse HEAD) ($TAG)."
297+
echo " 'main' is now open for the next minor."
298+
echo " Fixes for $LINE must be cherry-picked onto $BRANCH."

0 commit comments

Comments
 (0)