Files
speckle-blender/patch_version.py
T
Jedd Morgan 0add4fabec
Release workflow / Build Zip (push) Has been cancelled
Release workflow / deploy-installers (push) Has been cancelled
feat(installers): Add Installer building workflow (#237)
* New workflows for installer

* versioning

* installers test

* echo version

* echo again

* test21

* set version env

* Extensions manifest

* Add old bl_info

* fixed mistake

* removal of workspace

* Test end to end

* test envar cleanup

* main
2025-04-02 12:33:39 +01:00

49 lines
1.5 KiB
Python

import re
import sys
def patch_addon(simple_version: str):
"""Patches the __init__.py bl_info version within the connector init file"""
FILE_PATH = "bpy_speckle/__init__.py"
version = simple_version.split(".")
with open(FILE_PATH, "r") as file:
lines = file.readlines()
for (index, line) in enumerate(lines):
if '"version":' in line:
lines[index] = f' "version": ({version[0]}, {version[1]}, {version[2]}),\n'
with open(FILE_PATH, "w") as file:
file.writelines(lines)
def patch_manifest(simple_version: str):
"""Patches the connector version within the connector init file"""
FILE_PATH = "bpy_speckle/blender_manifest.toml"
version = simple_version.split(".")
with open(FILE_PATH, "r") as file:
lines = file.readlines()
for (index, line) in enumerate(lines):
if line.startswith('version ='):
lines[index] = f'version = "{version[0]}.{version[1]}.{version[2]}",\n'
print(f"Patched connector version number in {FILE_PATH}")
break
with open(FILE_PATH, "w") as file:
file.writelines(lines)
def main():
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}")
simple_version = tag.split("-")[0]
patch_addon(simple_version)
patch_manifest(simple_version)
if __name__ == "__main__":
main()