Clear sysproxy on core death; probe+reconnect; subscription prune; Best ignores soft UDP; Windows tray; Android protocol gate; CI workflows. Co-authored-by: Cursor <cursoragent@cursor.com>
83 lines
2.9 KiB
Python
Executable File
83 lines
2.9 KiB
Python
Executable File
#!/usr/bin/env python3
|
|
"""Sync versioninfo.json, build-macos.bat, Android gradle, UI badge from update.go."""
|
|
from __future__ import annotations
|
|
|
|
import json
|
|
import re
|
|
from pathlib import Path
|
|
|
|
ROOT = Path(__file__).resolve().parents[1]
|
|
UPDATE_GO = ROOT / "internal" / "update" / "update.go"
|
|
VERSIONINFO = ROOT / "versioninfo.json"
|
|
BUILD_BAT = ROOT / "build-macos.bat"
|
|
ANDROID_GRADLE = ROOT / "android" / "app" / "build.gradle.kts"
|
|
INDEX_HTML = ROOT / "internal" / "appui" / "index.html"
|
|
|
|
|
|
def read_consts() -> tuple[str, int]:
|
|
text = UPDATE_GO.read_text(encoding="utf-8")
|
|
m = re.search(r'CurrentVersion\s*=\s*"([^"]+)"', text)
|
|
b = re.search(r"const BuildNumber\s*=\s*(\d+)", text)
|
|
if not m or not b:
|
|
raise SystemExit("cannot parse CurrentVersion/BuildNumber from update.go")
|
|
return m.group(1), int(b.group(1))
|
|
|
|
|
|
def main() -> None:
|
|
ver, build = read_consts()
|
|
parts = [int(x) for x in ver.split(".")]
|
|
while len(parts) < 3:
|
|
parts.append(0)
|
|
major, minor, patch = parts[0], parts[1], parts[2]
|
|
full = f"{ver}.{build}"
|
|
display = f"{ver}+{build}"
|
|
version_code = major * 1_000_000 + minor * 10_000 + patch * 100 + build
|
|
|
|
data = json.loads(VERSIONINFO.read_text(encoding="utf-8"))
|
|
data["FixedFileInfo"]["FileVersion"] = {
|
|
"Major": major,
|
|
"Minor": minor,
|
|
"Patch": patch,
|
|
"Build": build,
|
|
}
|
|
data["FixedFileInfo"]["ProductVersion"] = dict(data["FixedFileInfo"]["FileVersion"])
|
|
data["StringFileInfo"]["FileVersion"] = full
|
|
data["StringFileInfo"]["ProductVersion"] = full
|
|
VERSIONINFO.write_text(json.dumps(data, ensure_ascii=False, indent=2) + "\n", encoding="utf-8")
|
|
print("updated", VERSIONINFO, "->", full)
|
|
|
|
bat = BUILD_BAT.read_text(encoding="utf-8")
|
|
bat2 = re.sub(
|
|
r'-version\s+\d+\.\d+\.\d+\s+-build\s+\d+\.\d+\.\d+\.\d+',
|
|
f"-version {ver} -build {full}",
|
|
bat,
|
|
)
|
|
if bat2 != bat:
|
|
BUILD_BAT.write_text(bat2, encoding="utf-8")
|
|
print("updated", BUILD_BAT, "->", ver, full)
|
|
else:
|
|
print("build-macos.bat already in sync")
|
|
|
|
if ANDROID_GRADLE.exists():
|
|
g = ANDROID_GRADLE.read_text(encoding="utf-8")
|
|
g2 = re.sub(r"versionCode\s*=\s*[\d_]+", f"versionCode = {version_code}", g)
|
|
g2 = re.sub(r'versionName\s*=\s*"[^"]+"', f'versionName = "{display}"', g2)
|
|
if g2 != g:
|
|
ANDROID_GRADLE.write_text(g2, encoding="utf-8")
|
|
print("updated", ANDROID_GRADLE, "->", display, version_code)
|
|
else:
|
|
print("android gradle already in sync")
|
|
|
|
if INDEX_HTML.exists():
|
|
h = INDEX_HTML.read_text(encoding="utf-8")
|
|
h2 = re.sub(r'(id="badgeVer">)[^<]+', rf"\g<1>{ver}", h, count=1)
|
|
if h2 != h:
|
|
INDEX_HTML.write_text(h2, encoding="utf-8")
|
|
print("updated", INDEX_HTML, "badge ->", ver)
|
|
else:
|
|
print("index.html badge already in sync")
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|