This commit is contained in:
+30
-53
@@ -1,26 +1,14 @@
|
||||
"""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.
|
||||
"""Cut the next release of the clone this tool ships in, the development clone; with --patch, a patch release of only the commits named.
|
||||
|
||||
usage: deploy-release [--cut | --cut-patch <commits>] [<checkout>]
|
||||
usage: cut-release [--patch <commits>]
|
||||
|
||||
<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,
|
||||
such as ~/code/claude-config. It prints the version it moved from and to, then CHANGELOG.md's
|
||||
section for each version since, so you can do what each asks, such as a new step under Install.
|
||||
Where the move changed settings.json, it asks you to pick the model again with /model, since git's
|
||||
clean filter keeps the model out of every commit.
|
||||
A clone of a release takes the release with its own bin/self-update.
|
||||
|
||||
It refuses, exit 1, and leaves the checkout as it was where a file the checkout tracks has an
|
||||
uncommitted change the newest tag doesn't hold: such as a hook Claude Code wrote into settings.json.
|
||||
Merge the change through the development clone and cut a release first. A model picked with /model
|
||||
is no such change. It also refuses where the newest tag doesn't hold the checkout's commit, since
|
||||
the move would drop work no release holds. Untracked files, such as Claude Code's sessions and
|
||||
memory, stay as they are.
|
||||
|
||||
--cut runs in the development clone, and refuses where that clone's origin isn't <checkout>'s. It cuts the next release, as chunk-preflight works it out, and
|
||||
It cuts the next release, as chunk-preflight works it out, and
|
||||
refuses without changing anything, unless that release holds no item in todo.md, its release review has
|
||||
landed, as chunk-preflight --help counts one, and changes are unreleased. The release names the version; the tool doesn't choose one. It also 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.
|
||||
with --patch.
|
||||
1. On a fresh origin/main, it renames ## Unreleased in CHANGELOG.md to the version, commits that
|
||||
titled `Cut release <version>`, and pushes it as the branch release-<version>. The clone's own
|
||||
checkout stays as it is. Where main has moved past the branch, it rebuilds the branch on main.
|
||||
@@ -30,18 +18,17 @@ with --cut-patch.
|
||||
minutes, naming any required check that never passed. GitHub has no fast-forward merge, so
|
||||
there it rebase-merges the branch, which is already on top of main.
|
||||
3. It tags the merged commit v<version>, annotated `Cut release <version>`, pushes only the tag,
|
||||
deletes the branch on origin, then moves <checkout> to the tag as above. A failed delete only warns.
|
||||
It says on stderr as each step finishes, and ends stdout, after the changelog, with the line
|
||||
`Done: v<version> is cut and pushed, and <checkout> is on it.`
|
||||
and deletes the branch on origin. A failed delete only warns.
|
||||
It says on stderr as each step finishes, and prints the line
|
||||
`Done: v<version> is cut and pushed. Each clone of a release takes it with its bin/self-update.`
|
||||
It keeps each of those lines, with its time in UTC, in the run's trace: a file of its own under
|
||||
$XDG_STATE_HOME/build-release/deploy-release (default ~/.local/state/build-release/deploy-release), named by when the run began. --cut-patch does too.
|
||||
$XDG_STATE_HOME/build-release/cut-release (default ~/.local/state/build-release/cut-release), named by when the run began. --patch does too.
|
||||
Where Ctrl-C or an unexpected fault ends the run, the trace ends with a line that starts `stopped:`.
|
||||
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.
|
||||
commit already merged, and drops a cut tag an earlier run made but never pushed. Once the tag is pushed, the release is cut.
|
||||
|
||||
--cut-patch <commits> runs in the development clone too, for a fix that must ship before main's other unreleased work. It
|
||||
--patch <commits> is for a fix that must ship before main's other unreleased work. It
|
||||
cuts the newest tag's next patch release, holding only <commits> on top of the tag. <commits> is a range as git log reads
|
||||
it, such as 794ce37..1aa2367, which leaves out 794ce37 as git's `..` does, or one commit, which it reads as that commit
|
||||
alone. Name the commits the fix's chunk merged, including the one that finished its item: the entries that commit added
|
||||
@@ -59,10 +46,10 @@ doesn't hold, and on a GitHub origin, whose rebase merge would drop the tag from
|
||||
4. It tags the commit v<version>, annotated `Cut release <version>`, and pushes only the tag.
|
||||
5. On a fresh origin/main it merges the tag keeping main's files, moves the release's entries from ## Unreleased to a
|
||||
## <version> section below it, commits that titled `Merge release <version> into main`, and lands it through the branch
|
||||
release-<version> and a pull request as --cut does. Then it checks main holds the tag.
|
||||
6. It moves <checkout> to the tag as above, and ends stdout as --cut does.
|
||||
release-<version> and a pull request as a cut without --patch does. Then it checks main holds the tag.
|
||||
It ends stdout as a cut without --patch does.
|
||||
A rerun takes a tag origin holds already, once it checks the tag lists the same changelog entries, and the merge-back's open
|
||||
pull request. Once the merge-back has merged, the release is cut: where only the move stopped, run a bare deploy-release.
|
||||
pull request. Once the merge-back has merged, the release is cut.
|
||||
"""
|
||||
import os
|
||||
import pathlib
|
||||
@@ -70,45 +57,35 @@ import shlex
|
||||
import sys
|
||||
import time
|
||||
|
||||
from deploy_release.ci_script import ci_runner, CI_SECONDS, removed_container
|
||||
from loop_state.paths import CLAUDE_HOME
|
||||
from deploy_release.cut import cut
|
||||
from deploy_release.patch import cut_patch
|
||||
from deploy_release.deploy import deploy
|
||||
from cut_release.ci_script import ci_runner, CI_SECONDS, removed_container
|
||||
from cut_release.cut import cut
|
||||
from cut_release.patch import cut_patch
|
||||
from failure import Failure
|
||||
from deploy_release import trace
|
||||
from loop_state.paths import RELEASE_ROOT
|
||||
from cut_release import trace
|
||||
|
||||
|
||||
def main(argv: list[str]) -> int:
|
||||
def main(argv: list[str], clone: str = str(RELEASE_ROOT)) -> int:
|
||||
"""Cut the next release of clone, which is the clone this tool ships in unless a test names another."""
|
||||
if argv[:1] in (["-h"], ["--help"]):
|
||||
print(__doc__.strip())
|
||||
return 0
|
||||
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)
|
||||
if argv and (argv[0] != "--patch" or len(argv) != 2 or argv[1].startswith("-")):
|
||||
print("cut-release: usage: cut-release [--patch <commits>]", file=sys.stderr)
|
||||
return 1
|
||||
checkout = rest[0] if rest else str(pathlib.Path.home() / CLAUDE_HOME)
|
||||
if not cutting and commits is None:
|
||||
moved = deploy(checkout)
|
||||
if isinstance(moved, Failure):
|
||||
print(f"deploy-release: {moved.reason}", file=sys.stderr)
|
||||
return 1
|
||||
print(moved)
|
||||
return 0
|
||||
clone, now = os.getcwd(), time.time
|
||||
commits = argv[1] if argv else None
|
||||
now = time.time
|
||||
folder, name = trace.trace_folder(os.environ, pathlib.Path.home()), trace.run_name(now(), os.getpid())
|
||||
begun = trace.started(folder, name, f"deploy-release {shlex.join([*argv[:2 if patching else 1], checkout])} in {clone}", now)
|
||||
begun = trace.started(folder, name, f"{shlex.join(['cut-release', *argv])} in {clone}", now)
|
||||
if isinstance(begun, Failure):
|
||||
print(f"deploy-release: warning: {begun.reason}", file=sys.stderr)
|
||||
print(f"cut-release: warning: {begun.reason}", file=sys.stderr)
|
||||
file = None if isinstance(begun, Failure) else begun
|
||||
say = trace.saying(file, now, sys.stderr)
|
||||
try:
|
||||
if commits is not None:
|
||||
moved = cut_patch(clone, checkout, commits, time.sleep, say, ci_runner(folder / f"{name}-ci.log", CI_SECONDS, say, f"deploy-release-ci-{name}", removed_container))
|
||||
moved = cut_patch(clone, commits, time.sleep, say, ci_runner(folder / f"{name}-ci.log", CI_SECONDS, say, f"cut-release-ci-{name}", removed_container))
|
||||
else:
|
||||
moved = cut(clone, checkout, time.sleep, say)
|
||||
moved = cut(clone, time.sleep, say)
|
||||
except BaseException as stopped:
|
||||
# Ctrl-C or a fault nobody foresaw: its traceback reaches only the terminal, so the trace says the run ended here.
|
||||
trace.kept(file, f"stopped: {stopped!r}", now, sys.stderr)
|
||||
@@ -118,5 +95,5 @@ def main(argv: list[str]) -> int:
|
||||
return 1
|
||||
print(moved)
|
||||
# The ending is on stdout already, so only the trace takes it.
|
||||
trace.kept(file, moved.splitlines()[-1], now, sys.stderr)
|
||||
trace.kept(file, moved, now, sys.stderr)
|
||||
return 0
|
||||
|
||||
Reference in New Issue
Block a user