Skip to content

Commit 93704b4

Browse files
authored
Merge pull request #3072 from lidge-jun/codex/promote-preview-23800831
[WRONG BRANCH] promote dev onto preview for v2.38.0-preview.20260831
2 parents dc3dd5b + f86c975 commit 93704b4

247 files changed

Lines changed: 19662 additions & 823 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 170 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,170 @@
1+
name: Dev version bump
2+
3+
# When a release publishes, open a pull request that moves `dev` past the published
4+
# version. Without this, `dev` keeps carrying a version that is at or behind a released
5+
# one, and `tests/release-version-line.test.ts` fails on `dev` and on every pull request
6+
# opened against it - inherited red a contributor cannot fix from their own diff.
7+
#
8+
# That has been repaired by hand four times: 32529c2b2, e4a85d134, 076ad3036, befcac3e1.
9+
# The second of those ADDED the detector and two more repairs followed it, so more
10+
# visibility was never the missing piece; a prepared change was.
11+
#
12+
# WHAT THIS DOES NOT DO. It does not push to `dev`. It opens a pull request and a human
13+
# merges it, because ruleset `Protect dev` requires an approving review and code-owner
14+
# sign-off that a bot cannot supply. Until that merge the red persists. This converts a
15+
# forgotten chore into a queued, reviewable change - not into an automatic repair.
16+
#
17+
# A `release` event resolves this workflow file from the repository DEFAULT branch
18+
# (`main`), not from `dev` - the same trap documented in cleanup-closed-pr-branches.yml.
19+
# So merging this file to `dev` installs it but arms nothing; it first fires after an
20+
# ordinary dev -> main promotion carries it there.
21+
#
22+
# There is deliberately no `workflow_dispatch`: a branch-selected manual run executes
23+
# THAT branch body with `contents: write`. Re-drive a missed run by running
24+
# `bun scripts/bump-dev-version.ts <released> package.json` locally and opening the pull
25+
# request normally.
26+
on:
27+
release:
28+
types: [published]
29+
30+
permissions: {}
31+
32+
concurrency:
33+
group: dev-version-bump
34+
cancel-in-progress: false
35+
36+
jobs:
37+
open-bump-pr:
38+
runs-on: ubuntu-latest
39+
permissions:
40+
# Push the new codex/dev-version-* branch. Ruleset `Protect dev` covers only
41+
# refs/heads/dev, so the bump branch is unprotected and this token cannot
42+
# bypass dev review. It is the ruleset that keeps this job off dev, not the
43+
# permission name.
44+
contents: write
45+
# Open the pull request.
46+
pull-requests: write
47+
steps:
48+
- name: Checkout dev
49+
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7
50+
with:
51+
ref: dev
52+
# Tags are load-bearing, not decoration: the freeness gate below is a bun
53+
# test that reads the local tag set, and release-version-line.test.ts
54+
# returns EARLY on an empty set. A shallow checkout would make that gate
55+
# silently vacuous instead of failing loudly.
56+
fetch-depth: 0
57+
# Do NOT set persist-credentials: false here as the read-only workflows do.
58+
# This job has to push its bump branch.
59+
60+
# The repository-owned composite action, not a hand-pinned setup-bun SHA: it
61+
# resolves the Bun version from package.json so the runtime SOT stays in one
62+
# place. An independently pinned action here would drift from every other job.
63+
- name: Setup project Bun
64+
uses: ./.github/actions/setup-project-bun
65+
66+
- name: Install dependencies
67+
run: bun install --frozen-lockfile
68+
69+
- name: Decide the version dev should carry
70+
id: decide
71+
env:
72+
RELEASED_VERSION: ${{ github.event.release.tag_name }}
73+
run: |
74+
set -euo pipefail
75+
bun scripts/bump-dev-version.ts "${RELEASED_VERSION}" package.json
76+
77+
- name: Prove the chosen version is unused
78+
if: ${{ steps.decide.outputs.changed == 'true' }}
79+
# The script decides the candidate from the released version SHAPE, which is all
80+
# a pure function can see. Whether that candidate is actually FREE is a property
81+
# of the tag set, so it is settled here by the detector that already owns the
82+
# question. If this fails, no pull request is opened and the job goes red asking
83+
# for a human decision - which is the correct outcome, not a fallback.
84+
run: bun test tests/release-version-line.test.ts
85+
86+
- name: Open the bump pull request
87+
if: ${{ steps.decide.outputs.changed == 'true' }}
88+
env:
89+
GH_TOKEN: ${{ github.token }}
90+
NEXT_VERSION: ${{ steps.decide.outputs.version }}
91+
RELEASED_VERSION: ${{ github.event.release.tag_name }}
92+
run: |
93+
set -euo pipefail
94+
95+
branch="codex/dev-version-${NEXT_VERSION}"
96+
97+
# Idempotent: a second publish, a re-run, or a manual repair must not turn a
98+
# successful release into a red job.
99+
#
100+
# Check the PULL REQUEST as well as the branch, not just the branch. A security
101+
# review caught that: an open bump pull request whose head branch was deleted
102+
# leaves the branch check passing, so the job would recreate the branch and then
103+
# fail on `gh pr create` with "already exists" — turning a successful release red
104+
# for a repair that was already queued.
105+
open_prs="$(gh pr list --base dev --head "${branch}" --state open --json number --jq 'length')"
106+
if [ "${open_prs}" != "0" ]; then
107+
echo "::notice::a bump pull request for ${branch} is already open; nothing to do"
108+
exit 0
109+
fi
110+
111+
# An existing branch is NOT terminal. If a previous run pushed the branch and then
112+
# failed at `gh pr create`, exiting here would leave the repair permanently unqueued
113+
# while every rerun reports success - the exact failure mode a reviewer caught. So
114+
# reuse the branch and fall through to pull-request creation instead.
115+
if git ls-remote --exit-code --heads origin "${branch}" >/dev/null 2>&1; then
116+
echo "::notice::${branch} exists without an open pull request; validating it"
117+
git fetch origin "${branch}"
118+
119+
# Fail closed on unexpected content. The branch carries the bot's own one-line
120+
# bump, so anything else on it means a human or another job is using that name and
121+
# this job must not push to it or open a pull request from it.
122+
changed_files="$(git diff --name-only "origin/dev...origin/${branch}")"
123+
if [ "${changed_files}" != "package.json" ]; then
124+
echo "::error::${branch} touches unexpected files: ${changed_files:-<none>}"
125+
exit 1
126+
fi
127+
branch_version="$(git show "origin/${branch}:package.json" | node -p "JSON.parse(require('fs').readFileSync(0,'utf8')).version")"
128+
if [ "${branch_version}" != "${NEXT_VERSION}" ]; then
129+
echo "::error::${branch} carries ${branch_version}, expected ${NEXT_VERSION}"
130+
exit 1
131+
fi
132+
git checkout -B "${branch}" "origin/${branch}"
133+
else
134+
git config user.name "github-actions[bot]"
135+
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
136+
git checkout -b "${branch}"
137+
git add package.json
138+
git commit -m "fix(release): move dev to ${NEXT_VERSION} after ${RELEASED_VERSION}"
139+
git push origin "${branch}"
140+
fi
141+
142+
gh pr create \
143+
--base dev \
144+
--head "${branch}" \
145+
--title "fix(release): move dev to ${NEXT_VERSION} after ${RELEASED_VERSION}" \
146+
--body "$(cat <<BODY
147+
## Summary
148+
149+
\`${RELEASED_VERSION}\` published, so \`dev\` would otherwise keep a version at or
150+
behind a released one and \`tests/release-version-line.test.ts\` would fail on
151+
\`dev\` and on every pull request opened against it. This moves \`dev\` to
152+
\`${NEXT_VERSION}\`.
153+
154+
Opened automatically by \`.github/workflows/dev-version-bump.yml\`. The same
155+
repair was previously done by hand in 32529c2b2, e4a85d134, 076ad3036, and
156+
befcac3e1.
157+
158+
## Verification
159+
160+
\`bun test tests/release-version-line.test.ts\` ran against this exact tree
161+
before the pull request was opened; the workflow refuses to open one if the
162+
chosen version collides with a published release.
163+
164+
## Checklist
165+
166+
- [x] Scope stays focused and avoids unrelated cleanup.
167+
- [x] Docs or release notes were updated when needed.
168+
- [x] Security-sensitive changes were reviewed for secrets, auth, and unsafe defaults.
169+
BODY
170+
)"

‎AGENTS.md‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -305,8 +305,11 @@ repository CI; a maintainer has to — so the gate never disproves it; a new
305305
push still resets every box. A disproved claim unticks the matching box and
306306
keeps the PR a draft.
307307
Authors with repository push permission skip the ancestry heuristic only. As with approval requirements in
308-
[`MAINTAINERS.md`](./MAINTAINERS.md), this is enforced by convention until
309-
branch protection is configured.
308+
[`MAINTAINERS.md`](./MAINTAINERS.md), the ancestry heuristic is a CI check
309+
rather than a branch rule. The branches themselves are protected: `dev`,
310+
`main`, and `preview` each carry an active ruleset requiring a reviewed pull
311+
request and blocking force-pushes and deletion, so a direct push to `dev` is
312+
rejected regardless of `--no-verify`.
310313

311314
[`MAINTAINERS.md`](./MAINTAINERS.md) is authoritative for review and merge
312315
policy (approvals, CI requirements, security review, promotion). This file

‎MAINTAINERS.md‎

Lines changed: 32 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,8 @@ when a maintainer steps down.
5252
a new push still resets every box. A disproved claim unticks the matching
5353
box and keeps the PR a draft.
5454
Authors with repository push permission skip the ancestry heuristic only. As
55-
with the approval requirement above, this is enforced by convention until
56-
branch protection is configured (see the note under the change log).
55+
with the approval requirement above, this part is enforced by convention;
56+
the ruleset does not check ancestry (see the note under the change log).
5757
- A pull request requires approval from at least one maintainer and successful required CI checks
5858
before merge.
5959
- Authors do not approve their own pull requests.
@@ -73,6 +73,21 @@ when a maintainer steps down.
7373
- Direct pushes are reserved for maintainer-owned integration work, urgent repairs, or incident
7474
recovery. The same CI and documentation requirements still apply.
7575
- Promotion from `dev` to `main` and npm releases is maintainer-controlled.
76+
- **Closing out a release includes moving `dev`'s version line forward.** A published
77+
release leaves `dev` carrying a version at or behind it, and
78+
`tests/release-version-line.test.ts` then fails on `dev` and on every pull request
79+
opened against it — red that contributors inherit and cannot fix from their own diff.
80+
This was repaired by hand four times (`32529c2b2`, `e4a85d134`, `076ad3036`,
81+
`befcac3e1`) before it was automated.
82+
83+
`.github/workflows/dev-version-bump.yml` now opens that bump as a pull request when a
84+
release publishes. Merging it is part of closing the release; a bot cannot, because
85+
`Protect dev` requires an approving review and code-owner sign-off. Two caveats worth
86+
knowing: the workflow runs from the DEFAULT branch, so it only fires once it has been
87+
promoted to `main`; and a pull request opened with `GITHUB_TOKEN` does not start
88+
`pull_request` workflows, so the bump pull request arrives without CI. To re-drive a
89+
missed run by hand: `bun scripts/bump-dev-version.ts <released-version> package.json`,
90+
then open the pull request normally.
7691

7792
## The retired `dev2-go` line
7893

@@ -145,11 +160,21 @@ Adding or removing a maintainer requires:
145160
and release automation keep the two owners already listed for those paths, so
146161
this addition does not widen the review surface for them.
147162

148-
CODEOWNERS requests reviews rather than enforcing them — no branch protection
149-
rule is configured on this repository, so code-owner approval is a convention
150-
here, not a gate. The same is true of the approval requirement in the review
151-
and merge policy above. Widening the security boundary, or enforcing either
152-
of these through branch protection, is a separate decision.
163+
Code-owner approval and the maintainer-approval requirement above are both
164+
enforced, not conventions. `dev`, `main`, and `preview` each carry an active
165+
repository ruleset — the classic `/branches/{branch}/protection` endpoint
166+
returns 404 for them, which is why this file long described the repository as
167+
unprotected. `Protect dev` (id 20763889) requires a pull request with one
168+
approving review, code-owner review, and extra approval for unattributed
169+
changes, and it blocks deletion and non-fast-forward pushes. Allowed merge
170+
methods are merge and squash; rebase merges are off.
171+
172+
The one carve-out is that the `maintain`/`admin` repository role holds a
173+
`pull_request` bypass, so an owner can merge without the approval the rules
174+
otherwise require. That is a bypass, not an exemption: "Authors do not approve
175+
their own pull requests" above still governs, and an owner who uses the bypass
176+
should record it on the pull request rather than leave it to be inferred from
177+
a merge timestamp. Widening the security boundary is a separate decision.
153178

154179
## Security reports
155180

0 commit comments

Comments
 (0)