Cut a patch release of only the commits named with deploy-release --cut-patch

This commit is contained in:
Lilleman
2026-11-24 14:09:56 +01:00
parent 80de753b9e
commit 9c2587b5ca
6 changed files with 389 additions and 24 deletions
+31 -8
View File
@@ -1,6 +1,6 @@
"""Move the checkout Claude Code reads its configuration from to this repo's newest release; with --cut, first cut the next release.
"""Move the checkout Claude Code reads its configuration from to this repo's newest release; with --cut, first cut the next release, and with --cut-patch, a patch release of only the commits named.
usage: deploy-release [--cut] [<checkout>]
usage: deploy-release [--cut | --cut-patch <commits>] [<checkout>]
<checkout> defaults to ~/.claude. The tool fetches origin's tags and checks out the newest v* tag,
detached, so the checkout holds only what a release holds. Development happens in another clone,
@@ -34,7 +34,25 @@ It says on stderr as each step finishes, and ends stdout, after the changelog, w
Where a step fails it stops, exit 1, with git's or the forge's reason, and leaves the pull request
and the branch as they are. A rerun continues: it takes the branch's open pull request and a cut
commit already merged, and drops a cut tag an earlier run made but never pushed. Once the tag is pushed, the release is cut: where only the
move stopped, fix what it names and run a bare deploy-release.
move stopped, fix what it names and run a bare deploy-release. --cut refuses a release that is a patch of the newest tag,
such as 0.15.2 after v0.15.1, since it would ship all of main: cut that with --cut-patch.
--cut-patch <commits> runs in the development clone too, for a fix that must ship before main's other unreleased work. It
cuts the newest tag's next patch release, such as 0.15.2 after v0.15.1, holding only <commits> on top of the tag. <commits>
is one revision as git log reads it: a range such as 794ce37..1aa2367, which leaves out 794ce37 as git's `..` does, or one
commit. Each must be on origin's main and not in the tag; merge commits are left out. Name the commit that finished the
fix's item too: its entries under ## Unreleased in CHANGELOG.md become the release's. todo.md must name the release and file
no item under it; a patch skips the release review. It refuses without changing anything where any of that doesn't hold.
1. In a worktree of its own at the tag, it applies each commit's changes, except to todo.md, CHANGELOG.md and the records
every chunk appends to, heads CHANGELOG.md with the release's section, and commits that titled `Cut release <version>`.
Where a commit doesn't apply, it stops and names it: cut that patch by hand.
2. It runs ci.sh on that commit, and stops where it fails, before anything is tagged.
3. It tags the commit v<version>, annotated `Cut release <version>`, and pushes only the tag.
4. On a fresh origin/main it merges the tag keeping main's files, moves the release's entries from ## Unreleased to a
## <version> section, commits that titled `Merge release <version> into main`, and lands it through the branch
release-<version> and a pull request as --cut does, so the tag is in main's history.
5. It moves <checkout> to the tag as above, and ends stdout as --cut does.
A rerun skips a tag origin holds already and a merge main holds already.
"""
import os
import pathlib
@@ -43,6 +61,7 @@ import time
from deploy_release.cut import cut
from deploy_release.deploy import deploy
from deploy_release.patch import cut_patch
from failure import Failure
@@ -50,13 +69,17 @@ def main(argv: list[str]) -> int:
if argv[:1] in (["-h"], ["--help"]):
print(__doc__.strip())
return 0
cutting = argv[:1] == ["--cut"]
rest = argv[1:] if cutting else argv
if len(rest) > 1 or rest[:1] and rest[0].startswith("-"):
print("deploy-release: usage: deploy-release [--cut] [<checkout>]", file=sys.stderr)
cutting, patching = argv[:1] == ["--cut"], argv[:1] == ["--cut-patch"]
commits = argv[1] if patching and len(argv) > 1 else None
rest = argv[2:] if patching else argv[1:] if cutting else argv
if len(rest) > 1 or rest[:1] and rest[0].startswith("-") or patching and (commits is None or commits.startswith("-")):
print("deploy-release: usage: deploy-release [--cut | --cut-patch <commits>] [<checkout>]", file=sys.stderr)
return 1
checkout = rest[0] if rest else str(pathlib.Path.home() / ".claude")
moved = cut(os.getcwd(), checkout, time.sleep) if cutting else deploy(checkout)
if commits is not None:
moved = cut_patch(os.getcwd(), checkout, commits, time.sleep)
else:
moved = cut(os.getcwd(), checkout, time.sleep) if cutting else deploy(checkout)
if isinstance(moved, Failure):
print(f"deploy-release: {moved.reason}", file=sys.stderr)
return 1