diff --git a/.claude/skills/release/SKILL.md b/.claude/skills/release/SKILL.md new file mode 100644 index 00000000..7bbadb21 --- /dev/null +++ b/.claude/skills/release/SKILL.md @@ -0,0 +1,73 @@ +--- +name: release +description: Release ensemble to prod — check stage, bump the version in a PR, publish the GitHub release, watch the deploy, and confirm what's live +disable-model-invocation: true +argument-hint: "[]" +allowed-tools: + - Bash(gh run list *) + - Bash(gh run view *) + - Bash(gh run watch *) + - Bash(gh release list *) + - Bash(gh release view *) + - Bash(gh pr list *) + - Bash(gh pr view *) + - Bash(git remote -v) + - Bash(git fetch *) + - Bash(git rev-parse *) + - Bash(git log *) + - Bash(git status *) + - Bash(curl -s https://data.firefox.com/version.json) + - Read + - Grep +--- + +# /release — Release to prod + +The steps are in "Releasing to prod" in `docs/architecture/deploy.md`. Read that section and +follow it; this file only adds what an agent needs to decide and when to stop for the user. If the +two disagree, the doc and `.github/workflows/deploy.yml` win; say so and suggest fixing this file. + +## Before anything + +1. Find the remote for `github.com/mozilla/ensemble` with `git remote -v`. It is often `mozilla` + rather than `origin`; this file calls it ``. Fetch it, then show: + - the latest prod release, leaving out drafts and pre-releases, which never reach prod + (`gh release list --exclude-drafts --exclude-pre-releases --limit 1`), and what prod reports + (`curl -s https://data.firefox.com/version.json`); + - the commits on `/main` since that release's tag, which are what this release ships; + - open PRs the user may want in first (`gh pr list`). +2. Check the stage deploy of `/main`'s tip. If it or its smoke test failed, find out why from + `gh run view --log-failed` before going on. A failed smoke test doesn't undo a deploy, so + stage may be serving the code even though the run is red. + +## Choosing the version + +If no version was given, propose one. Use the README's "Versioning" scheme, which isn't semver: the +first digit for major changes, the second for medium, the third for small. Explain the choice from +the commits since the last release. The user decides; the version number is hand-managed, so never +bump it without asking. + +## The bump PR + +Branch off `/main` as `bump-version-`, change only the three files the doc lists, +and open a PR titled "Bump version to " in the shape of #513. Leave the merge to the user. + +## Publishing + +Once the bump PR is merged, fetch again and take the SHA to release, usually the bump's merge commit. +Show the user any other commits that reached `main` since the version was chosen. Wait until that +SHA's stage deploy and smoke test have passed (`gh run list --workflow=deploy.yml --commit `). + +Publishing the release deploys to prod, which every visitor sees. Get an explicit go-ahead naming +the version and the SHA, then publish with `--target `, never `--target main`, which may have +moved on. Never pass `--prerelease`. + +## After + +Wait for the deploy run whose branch is the new tag, as the doc shows. Don't take the newest +release run straight after publishing; it may still be the previous release's. Check that run's +`headSha` is the SHA you released, then watch it to the end, including the smoke test. Check +`version.json` reports the new version and that SHA. Report the result plainly. If the smoke test +fails, the deploy still happened: read the failing tests and say whether the site or the test is at +fault. Suggest a rollback (re-running the deploy from the previous tag) only if the site itself is +broken, and only run one with the user's go-ahead. diff --git a/README.md b/README.md index a6013d0f..990435e1 100644 --- a/README.md +++ b/README.md @@ -27,7 +27,8 @@ Any of the environment variables in *.env* can be overridden. For example: Run `npm run build` to produce a static build in `build/` (Stylus, then Vite, then `version.json`; see `CONTRIBUTING.md` for the full command reference). See [`docs/architecture/deploy.md`](docs/architecture/deploy.md) for where that build is hosted and how it is deployed: pushes to `main` deploy to stage and GitHub releases deploy to prod, -via `.github/workflows/deploy.yml`. +via `.github/workflows/deploy.yml`. To release, follow "Releasing to prod" there, or run `/release` +in Claude Code. Any of the environment variables in *.env* can be overridden. diff --git a/docs/architecture/deploy.md b/docs/architecture/deploy.md index d6ca356c..540413b4 100644 --- a/docs/architecture/deploy.md +++ b/docs/architecture/deploy.md @@ -126,6 +126,36 @@ the public URL to serve the new bundle at the root and every route, checks an un and the hardware dataset still answers. A separate `smoke-test` job then runs the live Playwright project against the deployed URL. A failed smoke test does not undo the deploy; it flags it. +## Releasing to prod + +Releases are tagged with the bare version, `2.1.0`, not `v2.1.0`. Run `/release` in Claude Code to +be walked through these steps. + +1. **Bump the version** in a PR that touches `package.json`, `package-lock.json`, and the version + in `AGENTS.md`, as #513 did: `npm version 2.2.0 --no-git-tag-version`. The version isn't semver; + see "Versioning" in the README. Merge it just before releasing. +2. **Check stage.** Every push to `main` deploys to stage. Pick the commit to release, usually the + bump's merge commit, and wait for its stage deploy and smoke test to pass: + `gh run list --workflow=deploy.yml --commit `. +3. **Publish the release** from that exact commit. This creates the tag and starts the prod deploy: + `gh release create 2.2.0 --target --title 2.2.0 --generate-notes`. Use the SHA, not + `main`, which may have moved on to a commit stage hasn't checked. Don't mark it as a + pre-release: pre-releases test the release mechanics and never reach prod. +4. **Watch the deploy.** The run takes a few seconds to appear, and its branch is the tag, so wait + for that run rather than taking the latest one, which may be the previous release's: + + ```sh + until id=$(gh run list --workflow=deploy.yml --event=release --branch 2.2.0 --json databaseId -q '.[0].databaseId') && [ -n "$id" ]; do sleep 5; done + gh run watch "$id" --exit-status + ``` + + The `prod` environment needs no approval, only a tag. +5. **Confirm what's live:** `curl -s https://data.firefox.com/version.json` should report the new + version and the SHA you released. + +To re-run a prod deploy or roll back, run the workflow from the tag: +`gh workflow run deploy.yml --ref 2.0.0 -f environment=prod`. + ## How deploys have happened - Until 2018-07 the site ran on Heroku with the create-react-app buildpack (`app.json`,