Auto-bump build number on each compile; ship versioned Windows artifacts. Co-authored-by: Cursor <cursoragent@cursor.com>
43 lines
1.1 KiB
Python
43 lines
1.1 KiB
Python
#!/usr/bin/env python3
|
|
"""Increment BuildNumber in update.go, then sync versioninfo / macOS bat / Android."""
|
|
from __future__ import annotations
|
|
|
|
import re
|
|
import subprocess
|
|
import sys
|
|
from pathlib import Path
|
|
|
|
ROOT = Path(__file__).resolve().parents[1]
|
|
UPDATE_GO = ROOT / "internal" / "update" / "update.go"
|
|
|
|
|
|
def bump() -> int:
|
|
text = UPDATE_GO.read_text(encoding="utf-8")
|
|
m = re.search(r"const BuildNumber\s*=\s*(\d+)", text)
|
|
if not m:
|
|
raise SystemExit("cannot find BuildNumber in update.go")
|
|
n = int(m.group(1)) + 1
|
|
text2, count = re.subn(
|
|
r"const BuildNumber\s*=\s*\d+",
|
|
f"const BuildNumber = {n}",
|
|
text,
|
|
count=1,
|
|
)
|
|
if count != 1:
|
|
raise SystemExit("failed to rewrite BuildNumber")
|
|
UPDATE_GO.write_text(text2, encoding="utf-8")
|
|
print(f"BuildNumber: {m.group(1)} -> {n}", flush=True)
|
|
return n
|
|
|
|
|
|
def main() -> None:
|
|
bump()
|
|
sync = ROOT / "scripts" / "sync-version.py"
|
|
r = subprocess.run([sys.executable, str(sync)], cwd=ROOT, check=False)
|
|
if r.returncode != 0:
|
|
raise SystemExit(r.returncode)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|