Skip to content

Commit 4ea8b1f

Browse files
committed
ci: use git tags for Windows installer versioning
- Updated generate_iss.py to retrieve version from git describe. - Ensures Setup filename reflects the current tag version (e.g., pyCol_Setup_0.9.5.exe).
1 parent af695cc commit 4ea8b1f

File tree

1 file changed

+27
-7
lines changed

1 file changed

+27
-7
lines changed

scripts/generate_iss.py

Lines changed: 27 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,40 @@
1-
#!/usr/bin/env python3
2-
"""
3-
Generate Inno Setup script with version info from versioninfo.json.
4-
"""
51
import json
2+
import subprocess
3+
import re
64
from pathlib import Path
75

86

7+
def get_git_version():
8+
"""Retrieve version from git tags if available."""
9+
try:
10+
cmd = ["git", "describe", "--tags", "--always"]
11+
version = subprocess.check_output(cmd, stderr=subprocess.DEVNULL).decode("utf-8").strip()
12+
if version.startswith('v'):
13+
version = version[1:]
14+
# Extract base version (X.Y.Z) for the installer filename
15+
match = re.search(r"(\d+\.\d+\.\d+)", version)
16+
return match.group(1) if match else version
17+
except Exception:
18+
return None
19+
20+
921
def main():
1022
project_root = Path(__file__).parent.parent
1123

12-
# Load version info
24+
# Load fallback info from JSON
1325
with open(project_root / 'versioninfo.json', 'r', encoding='utf-8') as f:
1426
data = json.load(f)
1527

16-
fixed = data['FixedFileInfo']['ProductVersion']
17-
version = f"{fixed['Major']}.{fixed['Minor']}.{fixed['Patch']}"
28+
# Try Git version first, then fallback
29+
git_ver = get_git_version()
30+
if git_ver:
31+
version = git_ver
32+
print(f"Using Git version for ISS: {version}")
33+
else:
34+
fixed = data['FixedFileInfo']['ProductVersion']
35+
version = f"{fixed['Major']}.{fixed['Minor']}.{fixed['Patch']}"
36+
print(f"Fallback to JSON version for ISS: {version}")
37+
1838
string_info = data['StringFileInfo']
1939

2040
# Read template

0 commit comments

Comments
 (0)