Skip to content

Commit 0caed9c

Browse files
schlesseraclaude
andcommitted
Add an update-bundle skill for releasing the bundle end to end
The skill surveys every bundled package, asks the maintainer all milestone questions in one go, gets a single approval before tagging, and then refreshes the framework and bundle lockfiles and the automated tests, babysitting each pull request and run until it is green. To support it: - `wp maintenance release plan` lists in its JSON the items still open on the release milestone, open pull requests without an open milestone, commits pushed without a pull request, and the open milestones that can still be released. Pull requests that only change workflows, the README or other files synced from wp-cli/.github no longer call for a release. - `wp maintenance milestone assign` puts issues or pull requests on a milestone, creating it when asked. - `.maintenance/refresh-bundle-lock.sh` updates the wp-cli/* packages in the bundle's composer.lock and opens or updates a pull request. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 parent 735b320 commit 0caed9c

18 files changed

Lines changed: 1711 additions & 19 deletions
Lines changed: 290 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,290 @@
1+
---
2+
name: update-bundle
3+
description: Release every bundled WP-CLI package that has unreleased changes, then refresh the wp-cli/wp-cli-bundle lockfile and the automated tests until they are green. Use when asked to "update the bundle", cut package releases across the bundle, or refresh the bundle's lock files. Asks the maintainer every milestone question in one go, then gets a single approval before tagging anything.
4+
---
5+
6+
# Update the bundle
7+
8+
Takes the bundle from "packages have unreleased changes" to "every package is
9+
tagged, the bundle lockfile ships those tags, and the automated tests are
10+
green". Stops and hands over to the maintainer when something bigger than a
11+
routine fix turns up.
12+
13+
Run everything from the root of this `wp-cli-dev` checkout, where any `wp`
14+
executable picks up the `wp maintenance` commands through `wp-cli.yml`. Set
15+
`NO_COLOR=1` for every command whose output you read back.
16+
17+
The run has four phases. **Nothing is written to GitHub before the
18+
maintainer's answers in phase 2. Nothing is tagged before their approval in
19+
phase 3.**
20+
21+
1. Survey (read-only)
22+
2. Milestone questions, then milestone changes
23+
3. Release proposal, approval, then tagging
24+
4. Lockfiles and tests: framework, bundle, automated tests
25+
26+
Keep a running log in a scratch file, such as `update-bundle-state.md` in the
27+
session's scratch or temp folder (not in this repository). Record the answers,
28+
the tags created, and the PRs and workflow runs you are watching. Re-read it
29+
after a context compaction instead of re-asking the maintainer. `$SCRATCH`
30+
below stands for that folder.
31+
32+
## Phase 1: Survey
33+
34+
```bash
35+
wp maintenance doctor
36+
wp maintenance release plan --bundle --format=json > "$SCRATCH/plan.json"
37+
```
38+
39+
Stop if `doctor` reports a failed check. The plan takes a few hundred API
40+
requests, so the rate limit `doctor` shows should leave room for that.
41+
42+
`--bundle` covers every package in the composer.lock of wp-cli/wp-cli-bundle:
43+
the `*-command` packages, plus wp-cli-tests, php-cli-tools, spyc and
44+
wp-config-transformer. The wp-cli/wp-cli framework is not tagged here. The
45+
bundle tracks its `main` branch, see phase 4.
46+
47+
For each repository, the JSON holds:
48+
49+
| Field | Meaning |
50+
| --- | --- |
51+
| `status` | `up_to_date`, `ready` (`release.tag` can be generated as is) or `needs_human` |
52+
| `latest_tag` | The tag the default branch is compared against |
53+
| `pull_requests` | Merged since `latest_tag` that call for a release. Leaves out Dependabot and GitHub Actions PRs unless they are on a milestone, and PRs that only touch `.github/`, `README.md`, `AGENTS.md`, `.actrc` or `.editorconfig`. |
54+
| `blockers` | What `needs_human` is about, by `code`, see below |
55+
| `open_items` | Issues/PRs still open on the milestone the unreleased changes are on |
56+
| `open_pull_requests` | Open, non-draft, non-bot PRs that have no open milestone |
57+
| `direct_commits` | Commits pushed without a PR that change more than those development files |
58+
| `open_milestones` | Open milestones that are a version newer than `latest_tag`, lowest first |
59+
60+
## Phase 2: Milestone questions
61+
62+
Work out every question first, across all repositories. Then ask them all,
63+
grouped into as few `AskUserQuestion` calls as possible: up to 4 questions
64+
per call and up to 4 options per question, with "Other" always added
65+
automatically. Put the repository and PR numbers in every question, since the
66+
maintainer may see only the dialog. Only start the next call once the previous
67+
one has its answers, and make no change until every question is answered.
68+
69+
Name the milestones like this:
70+
71+
- **R**, the release milestone of a repository: `release.milestone` when
72+
`ready`. Otherwise the milestone the unreleased `pull_requests` are on.
73+
Otherwise the lowest of `open_milestones`. Otherwise a new milestone, one
74+
patch version above `latest_tag`.
75+
- **N**, the next milestone after R: the lowest of `open_milestones` above R.
76+
Otherwise a new milestone, one patch version above R.
77+
78+
Choosing a version is the maintainer's call. Propose the patch bump, and offer
79+
a minor bump as a second option when a merged PR adds a command, a subcommand
80+
or a flag.
81+
82+
Questions by blocker or field:
83+
84+
- **`no_milestone`** (merged PRs without one): "Ship #A, #B of `<repo>` in R?"
85+
The options are *Put on R* or *Skip this repo's release*. They are merged
86+
already, so a tag ships them either way, and leaving them off R only drops
87+
them from the release notes.
88+
- **`released_milestone`** (merged PRs on a milestone that is closed or tagged
89+
already): the same question. Answering *Put on R* moves them.
90+
- **`open_items`**: "`<repo>` R still has #X (open PR, by …) open. Wait for it
91+
or defer it?" The options are *Defer to N and release R now* or *Wait, so
92+
no release of `<repo>`*. Mention drafts and issues as such.
93+
- **`several_milestones`**: "The unreleased changes of `<repo>` are on X and
94+
Y. Which one should the release be?" The options are each milestone, plus
95+
*Skip*. All the PRs end up on the chosen one.
96+
- **`open_pull_requests`**: one multi-select question per repository, with up
97+
to 4 PRs per question (split longer lists): "Which open PRs of `<repo>`
98+
should go on M?" M is N when R is released in this run, and R otherwise.
99+
Leaving a PR unchecked leaves it alone. Open PRs never block a release.
100+
- **`direct_commits`**: "`<repo>` has commits pushed without a PR, which R
101+
would ship without mentioning them: `<sha> <message>`. Release anyway?" If a
102+
repository has direct commits but no merged PR, `release generate` can't
103+
release it. Report it for the maintainer to handle by hand.
104+
- **`invalid_version`, `no_version_tag`**: no question. List them in the final
105+
report as needing manual attention.
106+
107+
Then apply the answers. One call puts any number of items on a milestone, and
108+
creates it if needed:
109+
110+
```bash
111+
wp maintenance milestone assign <repo> <milestone> <number>... --create
112+
```
113+
114+
Then re-run `wp maintenance release plan <repo>... --format=json` for the
115+
repositories you changed. A repository the maintainer wanted released that is
116+
still not `ready` points to a misread answer or a new blocker. Ask about it
117+
instead of working around it.
118+
119+
## Phase 3: Release proposal and approval
120+
121+
Every repository that is now `ready` gets a proposal. Gather all of them
122+
before asking. For each one, preview the notes:
123+
124+
```bash
125+
wp maintenance release-notes <repo> <milestone> --source=pull-request
126+
```
127+
128+
Then show a single overview as a table, with these columns: repository,
129+
`latest_tag` → new tag, number of PRs, a one-line summary of the notes, and
130+
anything notable such as direct commits or deferred items. Below it, list what
131+
phase 4 will do. Then ask for approval in one `AskUserQuestion` call, which
132+
also settles how to merge in phase 4:
133+
134+
1. "Tag and release these N packages?" *Release all* / *Release all except…
135+
(say which in Other)* / *Cancel*.
136+
2. "The bundle requires a review before merging. How should the lockfile PRs
137+
be merged once green?" *Approve the bot's PR and merge; admin-merge my own*
138+
/ *Approve the bot's PR and merge; ask a reviewer for mine* / *Leave all
139+
merges to me*.
140+
141+
Then release each approved package:
142+
143+
```bash
144+
wp maintenance release generate <repo> --milestone=<milestone> --yes
145+
```
146+
147+
The command re-checks the plan and skips the release, with a warning, if
148+
anything changed in the meantime. Report every skip. Do not force it. Check
149+
each release afterwards with `gh release view v<milestone> --repo <repo>`.
150+
151+
Before phase 4, wait until Packagist lists every new version, or Composer
152+
won't find them. It usually takes a minute or two:
153+
154+
```bash
155+
curl -fsS "https://repo.packagist.org/p2/wp-cli/<package>.json" | jq -r '.packages[][].version' | head -3
156+
```
157+
158+
The package name can differ from the repository: wp-cli/spyc is
159+
`wp-cli/mustangostang-spyc`. If a version is missing after about 15 minutes,
160+
report it to the maintainer.
161+
162+
## Phase 4: Lockfiles and tests
163+
164+
Do the steps in this order. Each one updates `composer.lock` of the bundle,
165+
and running them at the same time makes the PRs conflict.
166+
167+
### 4a. Framework: the "Update wp-cli framework" workflow of the bundle
168+
169+
The wp-cli/wp-cli repository has no lockfile of its own. Its "lock refresh" is
170+
the `update-framework.yml` workflow of wp-cli/wp-cli-bundle. It runs
171+
`composer update wp-cli/wp-cli --with-all-dependencies`, which also brings in
172+
new releases of php-cli-tools and spyc, and opens or updates the
173+
`update-framework` PR. It runs daily and on every push to the bundle's `main`.
174+
175+
It counts as triggered already when one of its runs started after both the
176+
latest commit on wp-cli/wp-cli `main` and the last tag from phase 3:
177+
178+
```bash
179+
gh run list --repo wp-cli/wp-cli-bundle --workflow update-framework.yml --limit 5 \
180+
--json databaseId,event,status,conclusion,createdAt
181+
gh api repos/wp-cli/wp-cli/commits/main --jq '.commit.committer.date'
182+
```
183+
184+
Otherwise trigger it, and wait for the run you started:
185+
186+
```bash
187+
gh workflow run update-framework.yml --repo wp-cli/wp-cli-bundle --ref main
188+
```
189+
190+
Then find the PR with `gh pr list --repo wp-cli/wp-cli-bundle --head
191+
update-framework --state open`. No PR after a successful run means the
192+
lockfile was up to date already. Otherwise babysit it, see below.
193+
194+
### 4b. Bundle: bundled packages in the bundle's composer.lock
195+
196+
Start this only after the framework PR is merged or turned out to be
197+
unnecessary. Nothing in the bundle updates the bundled packages as a whole on
198+
its own. Dependabot opens one PR per package, and they close themselves once
199+
the lockfile has caught up. Preview, then open the PR:
200+
201+
```bash
202+
.maintenance/refresh-bundle-lock.sh --dry-run
203+
.maintenance/refresh-bundle-lock.sh
204+
```
205+
206+
The script moves only the `wp-cli/*` packages, never the framework or
207+
third-party dependencies, and only touches `composer.lock`. If its
208+
`update-bundled-packages` PR is open already, the script updates that PR and
209+
prints its URL. No output on stdout means the lockfile is up to date already.
210+
Each package should end up on the tag created in phase 3. If one doesn't,
211+
find out why before merging, usually a constraint in the bundle's
212+
`composer.json`.
213+
214+
If Composer cannot resolve the update, for example because a new release
215+
needs a newer third-party dependency, that is a bigger issue. Stop and report
216+
it.
217+
218+
### 4c. Automated tests: wp-cli/automated-tests
219+
220+
Check `config.lock` in its `composer.json` first.
221+
222+
- **`false`, as is the case today**: there is no lockfile. Every run resolves
223+
the bundle's `dev-main` afresh, so refreshing means running the suite once
224+
the bundle PR is merged:
225+
226+
```bash
227+
gh workflow run testing.yml --repo wp-cli/automated-tests --ref main
228+
```
229+
230+
Then babysit that run the way a PR is babysat. It fans out to about 150 jobs
231+
and takes a while.
232+
- **A committed `composer.lock`**: update it on a branch with
233+
`composer update 'wp-cli/*' --no-install`, open a PR, and babysit it.
234+
235+
## Babysitting a PR or run
236+
237+
**Waiting.** Use the harness's own facility to watch PRs or wait on background
238+
work if it has one. Otherwise run `gh pr checks <n> --repo <repo> --watch`, or
239+
`gh run watch <run-id> --repo <repo> --exit-status`, in the background. Don't
240+
poll in a tight loop.
241+
242+
**Triaging each failing check.** Read the job log first, with `gh run view
243+
<run-id> --repo <repo> --log-failed`, and classify the failure:
244+
245+
- **Pre-existing**: the same check fails on the latest run of the default
246+
branch too, so the PR didn't cause it. Example: "Audit locked dependencies"
247+
flagging an advisory in a third-party package. To tell, compare
248+
`wp maintenance dependencies audit --ref=<pr-branch>` with a run of the
249+
same command against the default branch. It also shows whether the affected
250+
packages ship in the Phar or are only needed for development. Ask the
251+
maintainer whether to merge anyway. Don't fix it as part of this run.
252+
- **Flaky**: a network timeout, a failed download from WordPress.org or
253+
GitHub, MySQL not starting, a rate limit, or a runner lost mid-job. Re-run
254+
the failed jobs once with `gh run rerun <run-id> --repo <repo> --failed`. A
255+
second identical failure is real.
256+
- **Minor, fix it**: the PR is out of date or conflicts with `main`, which
257+
re-running the workflow or the script fixes. Also small fixes confined to
258+
the PR's own files. Push the fix to the PR branch.
259+
- **Bigger, rope the human in**: a Behat or PHPUnit failure in a package's
260+
behaviour, which may be a regression in a new release, a Composer
261+
resolution failure, an audit failure that would need a third-party update
262+
past the Dependabot cooldown, or anything that needs a code change in
263+
another repository or another release.
264+
265+
Stop the run there. Report the PR or run link, the failing jobs, a short
266+
log excerpt, the package and PR most likely responsible, and the fixes you
267+
see. Phases that don't depend on the blocked one may go on, but 4a → 4b →
268+
4c depend on each other.
269+
270+
**Merging.** Only with every required check green, or with the maintainer's
271+
explicit go-ahead on a pre-existing failure. Follow the merge choice from
272+
phase 3:
273+
274+
```bash
275+
gh pr review <n> --repo <repo> --approve # bot-authored PRs only
276+
gh pr merge <n> --repo <repo> --squash # add --admin only for the maintainer's own PRs, if allowed
277+
```
278+
279+
Never approve a PR the authenticated account wrote itself. If merging is left
280+
to the maintainer, or a reviewer is needed, say so in the report and wait.
281+
282+
## Final report
283+
284+
End with:
285+
286+
- the releases, with tags and links, and every repository skipped, with the
287+
reason,
288+
- the milestone changes made,
289+
- the PRs merged and the automated-tests run, with links and conclusions,
290+
- anything waiting on the maintainer, and what exactly is needed.

‎.gitignore‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,15 @@
11
# Exclude all subfolders...
22
/*/
33
# except for the following.
4+
!/.claude/
45
!/.github/
56
!/.maintenance/
67
!/.readme-partials/
78
!/tests/
89

10+
# Only the skills of .claude/ are shared.
11+
/.claude/*
12+
!/.claude/skills/
13+
914
composer.lock
1015
*.log

‎.maintenance/bootstrap.php‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
WP_CLI::add_command( 'maintenance contrib-list', 'WP_CLI\Maintenance\Contrib_List_Command' );
1010
WP_CLI::add_command( 'maintenance dependencies', 'WP_CLI\Maintenance\Dependencies_Command' );
1111
WP_CLI::add_command( 'maintenance doctor', 'WP_CLI\Maintenance\Doctor_Command' );
12+
WP_CLI::add_command( 'maintenance milestone', 'WP_CLI\Maintenance\Milestone_Command' );
1213
WP_CLI::add_command( 'maintenance milestones-after', 'WP_CLI\Maintenance\Milestones_After_Command' );
1314
WP_CLI::add_command( 'maintenance milestones-since', 'WP_CLI\Maintenance\Milestones_Since_Command' );
1415
WP_CLI::add_command( 'maintenance release', 'WP_CLI\Maintenance\Release_Command' );

0 commit comments

Comments
 (0)