diff --git a/requirements.txt b/requirements.txt index 7172434..b106916 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,3 +1,3 @@ colorama==0.3.9 oletools==0.60 -pyinstaller==4.10 \ No newline at end of file +pyinstaller==6.3.0 diff --git a/scripts/linux/build b/scripts/linux/build new file mode 100755 index 0000000..cb4defc --- /dev/null +++ b/scripts/linux/build @@ -0,0 +1,9 @@ +#!/bin/bash + +set -e + +export PYTHON_ARCH=$(python -c "import sys;print('x64' if sys.maxsize > 2**32 else 'x86')") + +python ./scripts/linux/update-version-info.py +pyinstaller --onefile ./src/diff.py --name=git-xl-diff-$PYTHON_ARCH --version-file ./scripts/windows/git-xl-version-info.py --icon ./scripts/windows/git-xl-logo.ico +pyinstaller --onefile ./src/cli.py --name=git-xl-$PYTHON_ARCH --version-file ./scripts/windows/git-xl-version-info.py --icon ./scripts/windows/git-xl-logo.ico diff --git a/scripts/linux/update-version-info.py b/scripts/linux/update-version-info.py new file mode 100644 index 0000000..eae1427 --- /dev/null +++ b/scripts/linux/update-version-info.py @@ -0,0 +1,66 @@ +import os +import json +import re + +base_directory = os.path.join('scripts', 'linux') + +# read build number, repo tag name and git commit hash from env vars +build = os.getenv('APPVEYOR_BUILD_NUMBER', '0') +version = os.getenv('APPVEYOR_REPO_TAG_NAME', '0.0.0') +commit = os.environ['APPVEYOR_REPO_COMMIT'][:7] if os.getenv('APPVEYOR_REPO_COMMIT') else 'dev' + +print('-----------') +print('Version tag: %s' % version) +print('Build number: %s' % build) +print('Commit hash: %s' % commit) + +major, minor, patch = version.split('.') +print(f'Generate file version: {major}.{minor}.{patch}.{build}') +print('-----------') + + + +s = f"""VSVersionInfo( + ffi=FixedFileInfo( + filevers=({major}, {minor}, {patch}, {build}), + prodvers=({major}, {minor}, {patch}, {build}), + mask=0x3f, + flags=0x0, + OS=0x40004, + fileType=0x1, + subtype=0x0, + date=(0, 0) + ), + kids=[ + StringFileInfo( + [ + StringTable( + u'040904B0', + [StringStruct(u'CompanyName', u'Zoomer Analytics LLC'), + StringStruct(u'FileDescription', u'Git XL'), + StringStruct(u'FileVersion', u'{major}.{minor}.{patch}'), + StringStruct(u'InternalName', u'git-xl'), + StringStruct(u'LegalCopyright', u'Zoomer Analytics LLC'), + StringStruct(u'OriginalFilename', u'git-xl'), + StringStruct(u'ProductName', u'Git XL'), + StringStruct(u'ProductVersion', u'{major}.{minor}.{patch}')]) + ]), + VarFileInfo([VarStruct(u'Translation', [1033, 1200])]) + ] +)""" + +# update 'git-xl-version-info.py +path = os.path.join(base_directory, 'git-xl-version-info.py') +with open(path, 'w') as f: + f.write(s) + +# update git-xl.py (VERSION and COMMIT) +path = 'src/cli.py' +with open(path, 'r') as f: + s = f.read() + +s = re.sub("VERSION\s*=\s*('|\")\d\.\d.\d('|\")", f"VERSION = '{major}.{minor}.{patch}'", s, re.MULTILINE) +s = re.sub("GIT_COMMIT\s*=\s*('|\")[a-zA-Z0-9]*('|\")", f"GIT_COMMIT = '{commit}'", s, re.MULTILINE) + +with open(path, 'w') as f: + f.write(s)