mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-06-12 12:57:13 +02:00
managed to load VERSION file in yaml file - simplifies things
This commit is contained in:
@ -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)
|
||||
|
Reference in New Issue
Block a user