fix(release): verify final candidates and refresh SVG parser

This commit is contained in:
Xubin Ren committed 2026-10-28 16:54:41 +08:00
1 parent 4574a9b859
commit 19c18aaafd
7 files changed
+92 -10

No files matched your search

+33
View File
@@ -106,6 +106,32 @@ def prepare_preview(root: Path, output: Path, *, source_commit: str, base: str,
"candidate_commit": _git(output, "rev-parse", "HEAD")}
def prepare_stable(root: Path, output: Path, *, source_commit: str, version: str) -> dict[str, str]:
"""Copy an already versioned final commit without relabelling Preview bytes."""
source_commit = _commit(source_commit)
release_version(version)
parsed = Version(version)
if parsed.is_prerelease or parsed.is_postrelease:
raise ValueError("Stable preparation requires a final version")
root, output = root.resolve(), output.resolve()
if output.exists() or output == root or root in output.parents:
raise ValueError("Candidate output must be a new directory outside the source checkout")
if _git(root, "rev-parse", f"{source_commit}^{{commit}}") != source_commit:
raise ValueError("Source commit is not available in this repository")
original = {name: _git(root, "show", f"{source_commit}:{name}", trim=False) for name in VERSION_FILES}
if tomllib.loads(original["pyproject.toml"])["project"]["version"] != version:
raise ValueError("Stable source must already declare the requested final version")
if _version_changes(original["pyproject.toml"], original["nanobot/__init__.py"], version) != original:
raise ValueError("Stable version declarations need maintainer review")
if _git(root, "tag", "--list", f"v{version}"):
raise ValueError("Stable preparation must not reuse an existing stable tag")
_git(root, "clone", "--shared", "--no-checkout", "-c", "core.autocrlf=false", str(root), str(output))
hooks = output / ".git" / "candidate-hooks"
hooks.mkdir()
_git(output, "-c", f"core.hooksPath={hooks}", "checkout", "--detach", source_commit)
return {"version": version, "source_commit": source_commit, "candidate_commit": source_commit}
def _candidate_identity(root: Path, source_commit: str) -> tuple[str, str, str]:
_commit(source_commit)
candidate_commit = _git(root, "rev-parse", "HEAD")
@@ -322,6 +348,10 @@ def main() -> None:
prepare.add_argument("--base", required=True)
prepare.add_argument("--sequence", type=int, required=True)
prepare.add_argument("--output", type=Path, required=True)
stable = commands.add_parser("prepare-stable")
stable.add_argument("--source-commit", required=True)
stable.add_argument("--version", required=True)
stable.add_argument("--output", type=Path, required=True)
verify = commands.add_parser("verify")
verify.add_argument("--source-commit", required=True)
verify.add_argument("--artifacts", type=Path, required=True)
@@ -343,6 +373,9 @@ def main() -> None:
if args.command == "prepare":
print(json.dumps(prepare_preview(args.root, args.output, source_commit=args.source_commit,
base=args.base, sequence=args.sequence)))
elif args.command == "prepare-stable":
print(json.dumps(prepare_stable(args.root, args.output, source_commit=args.source_commit,
version=args.version)))
elif args.command == "verify":
manifest = verify_candidate(args.root, args.artifacts, source_commit=args.source_commit)
write_manifest(manifest, args.artifacts / "release-manifest.json")