swarm repositories / source
aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormain <main@swarm.moe>2026-04-25 15:30:35 -0400
committermain <main@swarm.moe>2026-04-25 15:30:35 -0400
commit201600891b941004ff9be83bf55c868f2a54fd78 (patch)
treee51851bec2e5a2f88ef1f8e70d054d9a3d6e1e36
parent4fd39e5996ff791e05dea5dad7d079de0fc2ac50 (diff)
downloadmemview-201600891b941004ff9be83bf55c868f2a54fd78.zip
Harden publish rollup
-rwxr-xr-xpublish.py28
1 files changed, 26 insertions, 2 deletions
diff --git a/publish.py b/publish.py
index e83b4d6..8a5cbee 100755
--- a/publish.py
+++ b/publish.py
@@ -14,10 +14,34 @@ def run(*argv: str) -> None:
subprocess.run(argv, cwd=ROOT, check=True)
+def output(*argv: str) -> str:
+ return subprocess.check_output(argv, cwd=ROOT, text=True).strip()
+
+
+def require_clean_worktree() -> None:
+ status = output("git", "status", "--porcelain")
+ if status:
+ print("[publish] dirty worktree; commit or stash before publishing", file=sys.stderr)
+ print(status, file=sys.stderr)
+ raise SystemExit(1)
+
+
+def sync_tracking_ref(remote: str) -> None:
+ head = output("git", "ls-remote", remote, "refs/heads/main").split()[0]
+ local = output("git", "rev-parse", "HEAD")
+ if head != local:
+ raise SystemExit(f"[publish] {remote}/main is {head}, expected {local}")
+ run("git", "update-ref", f"refs/remotes/{remote}/main", head)
+
+
def main() -> None:
+ require_clean_worktree()
run("./check.py", "install")
- run("git", "push", "swarm", "main")
- run("git", "push", "github", "main")
+ require_clean_worktree()
+ run("git", "push", "--follow-tags", "swarm", "main")
+ sync_tracking_ref("swarm")
+ run("git", "push", "--follow-tags", "github", "main")
+ sync_tracking_ref("github")
if __name__ == "__main__":