-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrelease.py
More file actions
92 lines (72 loc) · 2.85 KB
/
Copy pathrelease.py
File metadata and controls
92 lines (72 loc) · 2.85 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
"""Production release orchestration script for ShellPDF.
Automates:
1. Unit test suite execution
2. Icon assets validation
3. Windows registry script generation
4. PyInstaller executable compilation
5. Inno Setup installer compilation
6. Portable ZIP release packaging
"""
from __future__ import annotations
import os
import shutil
import subprocess
import sys
import zipfile
from pathlib import Path
PROJECT_ROOT = Path(__file__).resolve().parent
def run_unit_tests() -> None:
"""Execute unit test suite before release."""
print("Running pre-release unit test suite...")
cmd = [
sys.executable,
"-c",
"import logging; logging.disable(logging.CRITICAL); import unittest, sys; suite = unittest.defaultTestLoader.discover('tests'); res = unittest.TextTestRunner(stream=sys.stdout).run(suite); sys.exit(0 if res.wasSuccessful() else 1)",
]
res = subprocess.run(cmd, cwd=PROJECT_ROOT)
if res.returncode != 0:
print("Release aborted: Unit tests failed!")
sys.exit(1)
print("Pre-release unit tests passed cleanly!")
def run_build_pipeline() -> None:
"""Execute main build automation script."""
print("Running build pipeline...")
cmd = [sys.executable, "build.py"]
res = subprocess.run(cmd, cwd=PROJECT_ROOT)
if res.returncode != 0:
print("Release aborted: Build pipeline failed!")
sys.exit(1)
def create_portable_zip() -> Path:
"""Package standalone dist folder into portable release ZIP archive."""
print("Creating portable ZIP release archive...")
output_dir = PROJECT_ROOT / "output"
output_dir.mkdir(parents=True, exist_ok=True)
dist_shellpdf = PROJECT_ROOT / "dist" / "ShellPDF"
if not dist_shellpdf.exists():
print(f"Error: Dist folder not found at '{dist_shellpdf}'")
sys.exit(1)
zip_path = output_dir / "ShellPDF-v1.0.0-Portable.zip"
with zipfile.ZipFile(zip_path, "w", zipfile.ZIP_DEFLATED) as zip_file:
for root, _, files in os.walk(dist_shellpdf):
for file_name in files:
file_path = Path(root) / file_name
arcname = Path("ShellPDF") / file_path.relative_to(dist_shellpdf)
zip_file.write(file_path, arcname)
print(f"Created portable ZIP archive: '{zip_path}' ({zip_path.stat().st_size} bytes)")
return zip_path
def main() -> None:
"""Execute production release workflow."""
print("=" * 60)
print(" ShellPDF Production Release Orchestrator")
print("=" * 60)
run_unit_tests()
run_build_pipeline()
create_portable_zip()
print("=" * 60)
print("Release build completed successfully!")
print("Generated Artifacts:")
print(" 1. Portable ZIP: output/ShellPDF-v1.0.0-Portable.zip")
print(" 2. Inno Setup: output/ShellPDF-Setup-v1.0.0.exe (if ISCC available)")
print("=" * 60)
if __name__ == "__main__":
main()