File tree Expand file tree Collapse file tree 1 file changed +27
-7
lines changed
Expand file tree Collapse file tree 1 file changed +27
-7
lines changed Original file line number Diff line number Diff line change 1- #!/usr/bin/env python3
2- """
3- Generate Inno Setup script with version info from versioninfo.json.
4- """
51import json
2+ import subprocess
3+ import re
64from 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+
921def 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
You can’t perform that action at this time.
0 commit comments