Viewing Mode

Releasing

New here? Start with How your code reaches users, which follows one PR from your branch to production step by step. This page is the reference for running releases.

You test your own work as thoroughly as you like before anyone else spends time on it. On a team, a reviewer approves each PR’s code before it merges; how the PRs behave together is judged once per release, on staging, where a person’s judgment is what’s needed. Production runs a release someone checked, tagged so you can roll back to it, or a hotfix that couldn’t wait for one.

your branch The draft on your machine checked by you next The pile deploys nowhere checked by CI, after every merge release/<name> The book deploys to staging checked together main Published deploys to production earlier versions archived merge bin/release cut bin/release ship merge-back: the next release starts from what production runs

Every PR is a story. On your branch it’s a draft only you have read (the book kind, not a GitHub draft PR). Merged into next, it joins a pile of stories (next) that CI checks again, all together, after every merge. bin/release cut binds the pile into a book (the release branch) on staging, where people read the stories together for the first time, and bin/release ship publishes it. The version it replaces goes to the archive, tagged, ready to republish if you need to roll back. Forking sets up the branch rules with bin/branch-rules, and Deployment switches on the deploys.

Branch Deploys to Checked by Takes changes from
your PR’s branch your machine you, or the agent writing it your commits
next nowhere CI on every PR and again after every merge, plus a reviewer’s approval on a team feature PRs
release/<name> staging reviewers, working through each PR’s notes its cut from next, then fix, revert and hotfix PRs
main production nothing new: it runs the commit staging ran, or a hotfix release and hotfix PRs

Working alone, the flow is the same with fewer people in it. bin/branch-rules --solo drops the required approval, staging is optional (leave DEPLOY_STAGING unset), and each release still gets its changelog section, its tag and a commit to roll back to.

bin/release runs each step. Every command takes --dry-run. prepare, cut, ship and merge-back also take --wait: instead of returning at once, the command follows the PR it opened and prints a line at each stage, until the next step is yours.

Step Command
See where the release stands, and what to run next bin/release status
Name the release in the changelog bin/release prepare
Cut a release bin/release cut
Ship the reviewed commit bin/release ship
Merge main back after a hotfix bin/release merge-back
Check that shipped release notes are unchanged bin/release check

Before it merges

Test your own work before you ask for anyone else’s time. The specs cover what they can, and CI runs them on every PR. What they can’t cover is how a change looks, reads and feels, so run your branch with bin/dev and click through it. The onboarding flow you just built is easiest to judge now, while it’s the only thing that changed, not on staging next to someone else’s sign-in rewrite.

The PR template asks for three things the release depends on:

  • What the specs can’t show. The checks you made by hand, written as numbered steps someone else can repeat: where to go, what to do, what to expect. A reviewer works through them on staging, and an agent with a browser can follow them as written. If a step could be a system spec, write the spec instead: it then runs on every PR without anyone’s time.
  • Depends on. Any unreleased PR this one needs, so both stay in a release or come out of it together.
  • A changelog entry. A file of its own in changelog.d/, such as changelog.d/fix-login.md, with one line saying what changed for someone using the app, under a ### Added or ### Fixed heading if it fits one. Two PRs never edit the same lines, so their entries can’t conflict. prepare turns the files into the release’s notes, and refuses a release that has none.

An agent writing a PR takes the same path: run the suite, run the app, walk the steps, then write them into the PR. Steps a person can follow are steps an agent can follow, and the other way round, so write them once for both.

Keep each PR removable

One story per PR. A PR is easiest to check, to review and to pull out when it does one thing. Keep a refactor apart from the behavior change it makes easy, and open that PR first. Leave an unrelated fix you noticed on the way for its own PR. When a PR turns out to hold two stories, split it before anyone reviews it. An AI agent adds unrelated changes as it works unless asked not to, so ask it for the one change and read its diff for anything else.

A PR may have to come out of a release (Hold back a PR). That’s cheap only when it comes out cleanly:

  1. It needs no other unreleased PR, or it names that PR under “Depends on”.
  2. Its migrations only add. Add the new column here, stop reading the old one, and drop it in a later release. A reverted PR’s migration has already run on staging, and an added column left behind breaks nothing.
  3. Its backfills and one-off jobs are safe to run twice. A backfill can run on staging, come out with its PR, and run again when the PR comes back.

None of this needs tooling of its own, and the template ships none. A fork that wants it enforced can add strong_migrations (it refuses destructive migrations), maintenance_tasks (resumable backfills) or a feature flag gem such as Flipper, which switches a PR’s feature off instead of reverting it.

Prepare the changelog

bin/release prepare

PRs add their entries as files in changelog.d/. prepare opens a PR into next that gathers them, with any lines still under ## [Unreleased] in CHANGELOG.md, into a section for the release, such as ## v2026.10.27, and deletes the files. It folds repeated ### Added / ### Fixed / … subsections into one each, keeps an empty [Unreleased] above the new section, drops subsections with no entries, and turns on auto-merge, so the PR lands once its checks pass and any approval the rules require is given. It commits through a temporary index, so your checkout is never touched. It refuses while a release it named earlier hasn’t shipped yet. A fork can have it run itself once staging is free (When a release starts).

The naming happens on next, before the cut, so that work merged during review adds new entries that wait for the next release. Naming on the release branch instead would collide with them at the merge-back.

A release is named for the day. A second one the same day becomes 2026.10.27-2, then -3. The script skips any name already used by a tag or a release branch. Only one release is open at a time (see below), so the second one starts after the first has shipped.

In a fork, the template’s releases count as shipped. A fork made before bin/fork started its changelog clean carries the template’s release sections, but only the template tagged them. So bin/release also reads the tags of the template that .fork.yml names. A section counts as shipped when the template tagged it on a commit already in next. A release the fork names itself never takes a name the template has used. If the template is private and the token can’t read it, bin/release stops and says so.

A shipped release’s notes don’t change. CI runs bin/release check, which fails a PR that adds, removes or edits a line in a release section that has been tagged, and names the line. A late line belongs in a new file in changelog.d/, and ships with the next release.

Cut a release

bin/release cut

Run it once the changelog PR has merged. The release is the newest commit on next with no changelog entries waiting, in changelog.d/ or under [Unreleased]: the commit that named the release, or a later one if the PRs merged since added no entry. The first PR that adds one waits for the next release, its file still in changelog.d/, and cut says how many commits wait. However long after prepare you run it, the code in a release matches its “What ships”.

cut pushes that commit as release/<name>, which deploys to staging, and opens the release PR into main from the release template. The PR body names the branch, and its “What ships” section is that release’s changelog section.

A PR that merged while the changelog PR was still open can leave its entry waiting when the release was named, though its code is in the release. cut then refuses and lists those entries. Move them under ## v<name>, deleting their files, with a PR into next, and run cut again.

Only what CI passed. CI runs on every push to next, and cut refuses until it has passed on the commit it would cut. If it failed there, fix it by a PR into next with its changelog line under ## v<name>, so this release takes the fix, then run cut again. A file in changelog.d/ would leave the fix waiting for the next release, and cut would pick the failing commit again.

One release at a time. cut refuses while another release/* branch is open, because staging runs one build and a second candidate would replace the one under review. It also refuses until main is in next, meaning the last merge-back has landed, so the release PR doesn’t start out of date. It refuses a release that already shipped, too.

Review on staging

Review on staging, not on the PR’s diff. The release PR’s Commits tab names every PR in the release; work through each one’s “What the specs can’t show” steps. A fix for something found in review goes into the release branch by PR, and staging redeploys. A fix that next also needs reaches it through the merge-back.

When review approves, record the commit staging is running in the PR’s “Commit reviewed on staging” field. The repository’s Environments page shows it on the latest staging deployment. With staging switched off (DEPLOY_STAGING unset, common for a solo project), review the release branch however you test, and record its head commit (git rev-parse origin/release/<name>).

A fix made on the release branch puts its changelog line under that release’s ## v<name> section, not in a file in changelog.d/. A file there would reach next with the merge-back and be listed again in the next release.

On a repository whose rules require an approval, someone other than the author approves the release PR on GitHub before ship. That’s separate from the stakeholders’ sign-off on staging.

Hold back a PR

When some of the changes aren’t ready, revert them on the release branch, by PR, and ship the rest:

git switch -c hold-back-search origin/release/2026.10.27
git revert -m 1 <the feature's merge commit>
# also delete its line from the release's CHANGELOG.md section
git push -u origin hold-back-search
gh pr create --base release/2026.10.27 --title "Hold back search for this release"

A squash-merged PR has no merge commit, so revert its squash commit instead: git revert <its squash commit>.

List each held-back PR and its revert commit under “Held back”.

The revert reaches next too. After the release merges back, the held-back feature is gone from next as well. To bring it back, revert the revert on next by PR (git revert <the revert commit>), and put its changelog entry back in a file in changelog.d/. Don’t re-merge the feature branch: git sees its commits as already merged, so nothing comes back.

Ship it

bin/release ship

It finds the release PR waiting to ship and the commit staging’s last successful deploy ran, shows you both, and asks before it ships:

== Ship v2026.10.27 in me/app ==
  PR #42, release/2026.10.27 into main, at abc1234: the commit staging's last deploy ran
Ship abc1234? [y/N]

It refuses when the branch has moved past what staging ran, since that commit hasn’t been reviewed. Where staging deploys are off, it offers the branch’s head and says no staging deploy was found. To name them yourself, or where there’s no terminal to answer on, as in CI, pass both: bin/release ship <release PR> <commit reviewed on staging>. A short commit ID is enough; it must be the PR’s head.

It does three things:

  1. Merges with --match-head-commit <commit>, so only the reviewed commit ships. If the branch moved after review, GitHub refuses (“Head branch was modified”), and the new commit gets reviewed on staging first. The merge deploys production, and the release branch is deleted.
  2. Publishes a GitHub Release, v<name>, at the merge commit, with that release’s changelog section as its notes. Publishing creates the tag.
  3. Merges main back into next, as below.

If any step stops partway, run the same command again. It skips the merge when the PR is already merged, skips publishing when v<name> exists, and reuses a merge-back branch and PR that are already open.

If the PR was merged on GitHub instead, ship still checks the merge. It refuses to publish when the merged branch wasn’t at the commit it ships. With AUTO_RELEASE on, the workflow runs it for you; otherwise run it by hand, and cut reminds you, with the command, until you do.

Merge main back into next

ship does this itself. After a hotfix, run:

bin/release merge-back

It pushes a branch from main (merge-back/<name>, or merge-back/main-<commit> after a hotfix), opens its PR into next, brings it up to date, and turns on auto-merge with a merge commit. If GitHub can’t bring it up to date, it says so. A PR whose head is main itself can’t be brought up to date, since that would push to main, which is why a separate branch is needed. If next moves again before the PR merges, press Update branch. Keep it a merge commit: a squash or rebase leaves main out of next’s history, so every later release PR shows changes main already has, and can conflict on them.

When a release starts

By hand, a release starts when someone runs bin/release prepare. A fork can have it start whenever staging is free instead, so nothing waits in next longer than one review on staging. Add a RELEASE_TOKEN secret (below), set the AUTO_RELEASE repository variable to true (where), and .github/workflows/next_release.yml takes the first two steps itself:

  1. When any PR merges into next, it runs bin/release prepare --if-needed. That names a release only if none is under way and a changelog entry is waiting; otherwise it says why and stops. So a release starts when the last one’s merge-back lands, or with the first PR after a quiet spell.
  2. When CI finishes on next, it runs bin/release cut --if-needed, which cuts a release once one is named, deploying it to staging and opening its PR. If CI failed where the release would be cut, the run fails and says so, and GitHub tells whoever merged. Re-run a flake’s failed jobs, or merge a fix with its changelog line under the release’s section; the cut follows once CI passes.

Reviewers hear about it once, from the release PR. Shipping stays a person’s call: bin/release ship asks before it ships the commit staging ran. Merging the release PR on GitHub ships it too: the workflow then publishes the tag and merges main back. PRs from forks of this repository start nothing, since GitHub withholds the token from them; the next merge from a branch here, or prepare by hand, starts the release.

Set up the release token

The workflow needs its own token because GitHub runs no workflows on pull requests opened with a workflow’s built-in token, so the changelog PR’s checks would never start and it would never merge. With AUTO_RELEASE on and no token, each run stops at its first step with “RELEASE_TOKEN isn’t set”.

  1. On GitHub, open Settings → Developer settings → Personal access tokens → Fine-grained tokens → Generate new token.

  2. Under Repository access, choose Only select repositories and pick this repository.

  3. Under Permissions, set Contents and Pull requests to Read and write. Add Workflows too if GitHub later refuses a push that carries workflow changes.

  4. Choose an expiry, and note it. An expired token still counts as set, so the run gets past that first check and fails at its bin/release step instead; releases stop starting on their own until you replace it.

  5. Generate it, then store it as the secret. The command asks for the token, so it stays out of your shell history:

    gh secret set RELEASE_TOKEN --repo <owner>/<repo>
    
  6. Turn it on:

    gh variable set AUTO_RELEASE --body true --repo <owner>/<repo>
    

Paste the token only into that prompt. A token left in a file, an editor tab or a chat can be read by anything that sees it; if that happens, revoke it on the same settings page and make a new one.

Hotfix

A fix production can’t wait a release for goes straight to main:

git switch -c hotfix/sign-in-loop origin/main
# fix, commit, push
gh pr create --base main --title "Sign-in no longer loops after a password reset"

Merging it deploys production. A hotfix ships untagged: put its changelog entry in a file in changelog.d/, and the next release lists it under that release’s tag. Until then, rolling back to the last tag rolls back the hotfix too.

Then run bin/release merge-back. If a release branch is open, bring the fix into it through a branch from main with a PR into release/<name>.

In case of emergency

The rulesets give no one a bypass, admins included. When production is down and the PR path can’t carry the fix (CI itself is broken, say), an admin switches the blocking ruleset off, pushes, and switches it back on:

gh api 'repos/{owner}/{repo}/rulesets' --jq '.[] | "\(.id) \(.name)"'
gh api -X PUT 'repos/{owner}/{repo}/rulesets/<id>' -f enforcement=disabled
git -c branch-rules.off=main push origin hotfix/sign-in-loop:main
bin/branch-rules   # add --solo if the repo runs solo; turns every ruleset back on

branch-rules.off=main tells the pre-push hook that main’s ruleset is off for this one push; without it the hook refuses a push to main before running anything else. The rest of the hook still runs.

Rerunning bin/branch-rules puts back every ruleset exactly as config/github/rulesets/ describes it. Then merge main back into next as after any hotfix. A ruleset left disabled is the risk here, so rerun the script in the same sitting as the push.

Where this is heading

The release round spends reviewers’ time, so the aim is to need it less. A problem a reviewer finds by hand that a spec could have caught becomes a spec, and the “What the specs can’t show” lists get shorter. Once most releases pass staging untouched, a fork can loosen the flow a step at a time:

  1. Ask for an approval only on PRs that touch risky paths, such as sign-in, authorization, tenancy and migrations. List them in a CODEOWNERS file, set require_code_owner_review to true in config/github/rulesets/, and drop required_approving_review_count to 0. That combination isn’t tested here: confirm on a scratch repository that GitHub still asks for the code owner’s approval before you rely on it.
  2. Skip staging for releases that touch none of those paths.
  3. Run ship from CI too, once the release PR’s checks pass. cut already runs from CI when AUTO_RELEASE is on.

The last step is where Impatient Programming points: green merges itself. The tags, the changelog and rollback by commit stay the same at every step.

What makes it run

Four kinds of lever move a release along.

bin/release does the work. It runs the release_flow gem, which wraps git and the GitHub CLI: prepare names the release in the changelog and opens that as a PR into next, cut pushes release/<name> and opens its PR into main, and ship merges it, tags it and opens the merge-back. A person and a workflow run the same commands, so automating a step changes who runs it, not what it does. Each command names the repository it acts on in its first line.

Run by hand, its pushes go through your pre-push hook, except a commit already on origin: cut pushes a commit on next, the merge-back one on main, and both passed CI’s required checks on their way there. cut only cuts a commit whose CI run passed, and every branch it pushes lands through a PR whose required checks run again. If a push fails, it shows the end of what the hook said and saves the rest to tmp/release-push.log.

Workflows react to events. Each file in .github/workflows/ names the event that starts it:

Workflow Starts when Does
ci.yml a PR opens or updates; a push to next or main runs the checks
deploy.yml a push to release/** or main deploys: release branches to staging, main to production
next_release.yml a PR merges into next bin/release prepare --if-needed
next_release.yml CI finishes on a push to next bin/release cut --if-needed, which fails loudly if CI failed
next_release.yml a release PR merges into main bin/release ship on that PR at the commit that merged, which publishes the tag and merges main back

One step’s output is the next one’s event. cut pushing a release branch is what deploys staging, and the changelog PR merging is a push to next, which runs CI, whose passing starts the cut.

GitHub’s PR features keep it moving. Auto-merge lands the changelog and merge-back PRs once their checks pass, and once approved where the rules ask for an approval. The branch rules from bin/branch-rules make every change to next, release/* and main a PR with passing checks, and delete branches once they merge, which is how bin/release tells that a release is still under way: its branch still exists.

Repository settings are the switches. DEPLOY_STAGING and DEPLOY_PRODUCTION turn on the deploys, and AUTO_RELEASE turns on next_release.yml. RELEASE_TOKEN is the token that workflow acts with, because GitHub runs no checks on a PR opened with a workflow’s built-in token, so the changelog PR would never merge.

With every switch on, one release runs like this:

  1. A PR merges into next. CI checks next, and prepare names a release if staging is free and something is waiting.
  2. The changelog PR merges itself. CI checks next again.
  3. CI passes, so the cut pushes release/<name>, staging deploys it, and the release PR opens.
  4. A person reviews it on staging and runs bin/release ship. Production deploys, the merge-back merges itself, and that merge starts step 1 for the next release.

Step 4 is the only one that needs a person, apart from approvals on a team.

Changing the flow

The flow is a default, not a requirement. The branch rules live in config/github/rulesets/, the checks in .github/workflows/ci.yml (which bin/release cut reads by name), the deploys in .github/workflows/deploy.yml, the automatic start in .github/workflows/next_release.yml, the steps in the release_flow gem behind bin/release, and this page, the release template in .github/PULL_REQUEST_TEMPLATE/release.md and the PR template in .github/PULL_REQUEST_TEMPLATE.md describe them. Change all of them together.

bin/release takes its names from .release_flow.yml at the repository’s root. A setting the file leaves out takes the gem’s default:

Setting Here What it names
integration_branch next the branch PRs merge into
production_branch main the branch production deploys
ci_workflow ci.yml the workflow cut waits on
staging_workflow deploy.yml the workflow whose deploys ship reads
guide /docs/developer/releasing the page bin/release --help points to
template from .fork.yml in a fork the GitHub repository this one forks, as owner/repo

A setting it doesn’t know stops bin/release with the list of those it does. The workflow next_release.yml and the branch rules name the branches too, so rename them there as well.

The changelog and release-name convention is separate from the flow. It lives in the gem’s ReleaseFlow::Changelog, and the flow reads it only through that module’s public methods. A fork that keeps its changelog another way reopens that module in bin/release, after require "release_flow", and keeps the method signatures. In a fork, bin/release reads the template from template_url in .fork.yml, which bin/fork writes, unless .release_flow.yml names one.