fix(bootstrap-installer): stamp setup app version from release semver

Fixes #107177

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
KoNit-K
2026-09-10 16:13:35 +08:00
committed by jonny
parent 04dd80a977
commit 0b8daf30aa
5 changed files with 202 additions and 4 deletions
+55 -1
View File
@@ -2230,6 +2230,60 @@ def update_version_files(semver: str, calver_date: str):
)
desktop_pkg.write_text(pkg_text, encoding="utf-8")
# Keep the bootstrap installer (Hermes-Setup.dmg CFBundleShortVersionString)
# in lockstep with the Python package version. Tauri reads `version` from
# package.json + tauri.conf.json; a hardcoded 0.0.1 ships in the DMG.
installer_pkg = REPO_ROOT / "apps" / "bootstrap-installer" / "package.json"
if installer_pkg.exists():
pkg_text = installer_pkg.read_text(encoding="utf-8")
pkg_text = re.sub(
r'("version"\s*:\s*)"[^"]+"',
rf'\g<1>"{semver}"',
pkg_text,
count=1,
)
installer_pkg.write_text(pkg_text, encoding="utf-8")
installer_tauri = (
REPO_ROOT / "apps" / "bootstrap-installer" / "src-tauri" / "tauri.conf.json"
)
if installer_tauri.exists():
pkg_text = installer_tauri.read_text(encoding="utf-8")
pkg_text = re.sub(
r'("version"\s*:\s*)"[^"]+"',
rf'\g<1>"{semver}"',
pkg_text,
count=1,
)
installer_tauri.write_text(pkg_text, encoding="utf-8")
installer_cargo = (
REPO_ROOT / "apps" / "bootstrap-installer" / "src-tauri" / "Cargo.toml"
)
if installer_cargo.exists():
cargo_text = installer_cargo.read_text(encoding="utf-8")
cargo_text = re.sub(
r'^version\s*=\s*"[^"]+"',
f'version = "{semver}"',
cargo_text,
count=1,
flags=re.MULTILINE,
)
installer_cargo.write_text(cargo_text, encoding="utf-8")
def version_files_to_stage() -> list[str]:
"""Return version-bearing files that exist and should be `git add`ed after a bump."""
candidates = [
VERSION_FILE,
PYPROJECT_FILE,
REPO_ROOT / "apps" / "desktop" / "package.json",
REPO_ROOT / "apps" / "bootstrap-installer" / "package.json",
REPO_ROOT / "apps" / "bootstrap-installer" / "src-tauri" / "tauri.conf.json",
REPO_ROOT / "apps" / "bootstrap-installer" / "src-tauri" / "Cargo.toml",
]
return [str(path) for path in candidates if path.exists()]
def resolve_author(name: str, email: str) -> str:
"""Resolve a git author to a GitHub @mention."""
@@ -2568,7 +2622,7 @@ def main():
print(f" ✓ Updated version files to v{new_version} ({calver_date})")
# Commit version bump
add_files = [str(VERSION_FILE), str(PYPROJECT_FILE)]
add_files = version_files_to_stage()
add_result = git_result("add", *add_files)
if add_result.returncode != 0:
print(f" ✗ Failed to stage version files: {add_result.stderr.strip()}")