feat: Implement centralized version management and sync process
This commit is contained in:
parent
c1133ae8e9
commit
0d9464854d
7 changed files with 523 additions and 45 deletions
|
|
@ -19,6 +19,9 @@ import shutil
|
|||
from pathlib import Path
|
||||
from datetime import datetime
|
||||
|
||||
# Import shared version utilities
|
||||
from version_utils import get_current_version
|
||||
|
||||
# Fix Unicode output on Windows
|
||||
if sys.platform == "win32":
|
||||
import io
|
||||
|
|
@ -37,16 +40,15 @@ class WindowsBuilder:
|
|||
self.dist_dir = self.build_dir / "dist" / "windows"
|
||||
self.temp_dir = self.build_dir / "temp" / "windows"
|
||||
self.spec_file = self.build_dir / "webdrop_bridge.spec"
|
||||
self.version = self._get_version()
|
||||
self.version = get_current_version()
|
||||
|
||||
def _get_version(self) -> str:
|
||||
"""Get version from config.py."""
|
||||
config_file = self.project_root / "src" / "webdrop_bridge" / "config.py"
|
||||
for line in config_file.read_text().split("\n"):
|
||||
if "app_version" in line and "1.0.0" in line:
|
||||
# Extract default version from config
|
||||
return "1.0.0"
|
||||
return "1.0.0"
|
||||
"""Get version from __init__.py.
|
||||
|
||||
Note: This method is deprecated. Use get_current_version() from
|
||||
version_utils.py instead.
|
||||
"""
|
||||
return get_current_version()
|
||||
|
||||
def clean(self):
|
||||
"""Clean previous builds."""
|
||||
|
|
@ -322,28 +324,27 @@ class WindowsBuilder:
|
|||
return True
|
||||
|
||||
|
||||
def main():
|
||||
"""Main entry point."""
|
||||
import argparse
|
||||
def sync_version() -> None:
|
||||
"""Sync version from __init__.py to all dependent files."""
|
||||
script_path = Path(__file__).parent.parent.parent / "scripts" / "sync_version.py"
|
||||
result = subprocess.run(
|
||||
[sys.executable, str(script_path)],
|
||||
capture_output=True,
|
||||
text=True,
|
||||
)
|
||||
if result.returncode != 0:
|
||||
print(f"❌ Version sync failed: {result.stderr}")
|
||||
sys.exit(1)
|
||||
print(result.stdout)
|
||||
|
||||
parser = argparse.ArgumentParser(
|
||||
description="Build WebDrop Bridge for Windows"
|
||||
)
|
||||
parser.add_argument(
|
||||
"--msi",
|
||||
action="store_true",
|
||||
help="Create MSI installer (requires WiX Toolset)",
|
||||
)
|
||||
parser.add_argument(
|
||||
"--sign",
|
||||
action="store_true",
|
||||
help="Sign executable (requires CODE_SIGN_CERT environment variable)",
|
||||
)
|
||||
|
||||
args = parser.parse_args()
|
||||
def main() -> int:
|
||||
"""Build Windows MSI installer."""
|
||||
print("🔄 Syncing version...")
|
||||
sync_version()
|
||||
|
||||
builder = WindowsBuilder()
|
||||
success = builder.build(create_msi=args.msi, sign=args.sign)
|
||||
success = builder.build(create_msi=True, sign=False)
|
||||
|
||||
return 0 if success else 1
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue