Skip to content

Instantly share code, notes, and snippets.

@saqwed
Forked from JarekParal/README.md
Created April 19, 2022 14:38
Show Gist options
  • Save saqwed/40cee47dabf13a61f4de1e42a0eec09c to your computer and use it in GitHub Desktop.
Save saqwed/40cee47dabf13a61f4de1e42a0eec09c to your computer and use it in GitHub Desktop.

Revisions

  1. @JarekParal JarekParal created this gist Dec 9, 2019.
    4 changes: 4 additions & 0 deletions README.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,4 @@
    ```sh
    python CI/updateVersion.py %NEW_VERSION%
    pyinstaller testApp.py --version-file "CI/version.py"
    ```
    38 changes: 38 additions & 0 deletions updateVersion.py
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,38 @@
    import sys
    import re

    FILE_WITH_VERSION_INFORMATIONS = "CI\\version"

    if len(sys.argv) != 2:
    print("""Problem with argument.\n
    Expected exactly one argument with new version number - e.g. '1.23.0.0'""")
    exit(1)

    new_version = sys.argv[1]

    if re.match(r"[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+", new_version) == None:
    print("Wrong format of argument:", new_version,
    "\nRequired format: 1.23.0.0")
    exit(1)

    new_version_commas = new_version.replace('.', ', ')

    # Read data from template file
    fin = open(FILE_WITH_VERSION_INFORMATIONS + "_template.py", "rt")
    data = fin.read()
    data = data.replace('filevers=(78, 0, 3904, 108)',
    'filevers=(' + new_version_commas + ')')
    data = data.replace('prodvers=(78, 0, 3904, 108)',
    'prodvers=(' + new_version_commas + ')')
    data = data.replace("u'FileVersion', u'78, 0, 3904, 108'",
    "u'FileVersion', u'" + new_version + "'")
    data = data.replace("u'ProductVersion', u'78, 0, 3904, 108'",
    "u'ProductVersion', u'" + new_version + "'")
    fin.close()

    # Write the data to new output file
    fin = open(FILE_WITH_VERSION_INFORMATIONS + ".py", "wt")
    fin.write(data)
    fin.close()

    print(sys.argv[0], "- version updated to:", new_version)
    50 changes: 50 additions & 0 deletions version_template.py
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,50 @@
    # Version info from Google Chrome
    # Get this info with util `pyi-grab_version`

    # UTF-8
    #
    # For more details about fixed file info 'ffi' see:
    # http://msdn.microsoft.com/en-us/library/ms646997.aspx
    VSVersionInfo(
    ffi=FixedFileInfo(
    # filevers and prodvers should be always a tuple with four items: (1, 2, 3, 4)
    # Set not needed items to zero 0.
    filevers=(78, 0, 3904, 108),
    prodvers=(78, 0, 3904, 108),
    # Contains a bitmask that specifies the valid bits 'flags'r
    mask=0x17,
    # Contains a bitmask that specifies the Boolean attributes of the file.
    flags=0x0,
    # The operating system for which this file was designed.
    # 0x4 - NT and there is no need to change it.
    OS=0x4,
    # The general type of file.
    # 0x1 - the file is an application.
    fileType=0x1,
    # The function of the file.
    # 0x0 - the function is not defined for this fileType
    subtype=0x0,
    # Creation date and time stamp.
    date=(0, 0)
    ),
    kids=[
    StringFileInfo(
    [
    StringTable(
    u'040904b0',
    [StringStruct(u'CompanyName', u'Google LLC'),
    StringStruct(u'FileDescription', u'Google Chrome'),
    StringStruct(u'FileVersion', u'78, 0, 3904, 108'),
    StringStruct(u'InternalName', u'chrome_exe'),
    StringStruct(u'LegalCopyright', u'Copyright 2019 Google LLC. All rights reserved.'),
    StringStruct(u'OriginalFilename', u'chrome.exe'),
    StringStruct(u'ProductName', u'Google Chrome'),
    StringStruct(u'ProductVersion', u'78.0.3904.108'),
    StringStruct(u'CompanyShortName', u'Google'),
    StringStruct(u'ProductShortName', u'Chrome'),
    StringStruct(u'LastChange', u'4b26898a39ee037623a72fcfb77279fce0e7d648-refs/branch-heads/3904@{#889}'),
    StringStruct(u'Official Build', u'1')])
    ]),
    VarFileInfo([VarStruct(u'Translation', [1033, 1200])])
    ]
    )