managed to load VERSION file in yaml file - simplifies things

This commit is contained in:
mazzol_a
2025-04-23 14:26:26 +02:00
parent fca31cc432
commit 497c3abfc2
6 changed files with 12 additions and 49 deletions

View File

@ -6,10 +6,7 @@ Script to update VERSION file with semantic versioning if provided as an argumen
import sys
import re
import os
import toml
import yaml
from jinja2 import Template, Undefined
def get_version():
@ -26,31 +23,20 @@ def get_version():
return version
def write_version_to_file(version):
with open("VERSION", "w") as version_file:
version_file.write(version)
print(f"Version {version} written to VERSION file.")
def define_environment_variable(version):
os.environ["VERSION"] = version
def update_pyproject_toml_file(version):
pyproject = toml.load("pyproject.toml")
pyproject["project"]["version"] = version
toml.dump(pyproject, open("pyproject.toml", "w")) #write back
print(f"Version in pyproject.toml set to {version}")
class NullUndefined(Undefined):
def __getattr__(self, key):
return ''
# Main script
if __name__ == "__main__":
version = get_version()
write_version_to_file(version)
define_environment_variable(version)
update_pyproject_toml_file(version)