Files
speckle-sketchup/patch_version.py
T
Oğuzhan Koral 5b91a04e1e Feat(dui3): v3 installer build test (#351)
* Create v3-fake.yml

* Run on PR

* Disable patching iss

* Fix typoo

* Rename artifact to sketchup

* Add deployment steps

* Do not name artifact name

* Define which branch to build installer

* Align CI installers with new branch and files

* Get patch installer back

* Remove circleci again

* Rename file and enable tags

* Test enabling PR runs

* Test nested folders

* Test single path dll

* add all things

* try zipping manually first

* don't need sub dir

* rename zip

* Use version from env variables

* Test git version

* More test

* Test

* Revert

* install gitversion

* test

* Use hardcoded version

* Remove pull request trigger

---------

Co-authored-by: Adam Hathcock <adam@speckle.systems>
2024-08-02 15:08:20 +03:00

53 lines
1.3 KiB
Python

import re
import sys
def patch_connector(tag):
"""Patches the connector version within the connector file"""
rb_file = "speckle_connector_3.rb"
with open(rb_file, "r") as file:
lines = file.readlines()
for (index, line) in enumerate(lines):
if 'CONNECTOR_VERSION = ' in line:
lines[index] = f' CONNECTOR_VERSION = "{tag}"\n'
print(f"Patched connector version number in {rb_file}")
break
with open(rb_file, "w") as file:
file.writelines(lines)
def patch_installer(tag):
"""Patches the installer with the correct connector version"""
iss_file = "speckle-sharp-ci-tools/sketchup.iss"
with open(iss_file, "r") as file:
lines = file.readlines()
lines.insert(11, f'#define AppVersion "{tag.split("-")[0]}"\n')
lines.insert(12, f'#define AppInfoVersion "{tag}"\n')
with open(iss_file, "w") as file:
file.writelines(lines)
print(f"Patched installer with connector v{tag}")
def main():
if len(sys.argv) < 2:
return
tag = sys.argv[1]
if not re.match(r"([0-9]+)\.([0-9]+)\.([0-9]+)", tag):
raise ValueError(f"Invalid tag provided: {tag}")
print(f"Patching version: {tag}")
patch_connector(tag)
# patch_installer(tag)
if __name__ == "__main__":
main()