From 791639bbe73da875fe3cb7deb29df26698f4c039 Mon Sep 17 00:00:00 2001 From: Michel Fedde <35878897+Neintonine@users.noreply.github.com> Date: Mon, 29 Jan 2024 21:57:05 +0100 Subject: [PATCH] adds build code --- .version | 1 + build/.version | 1 + build/build.py | 23 +++++++++++++++++++++++ build/bump_major_version.py | 12 ++++++++++++ build/bump_minor.py | 8 ++++++++ build/versioning.py | 19 +++++++++++++++++++ 6 files changed, 64 insertions(+) create mode 100644 .version create mode 100644 build/.version create mode 100644 build/build.py create mode 100644 build/bump_major_version.py create mode 100644 build/bump_minor.py create mode 100644 build/versioning.py diff --git a/.version b/.version new file mode 100644 index 0000000..afaf360 --- /dev/null +++ b/.version @@ -0,0 +1 @@ +1.0.0 \ No newline at end of file diff --git a/build/.version b/build/.version new file mode 100644 index 0000000..11e28da --- /dev/null +++ b/build/.version @@ -0,0 +1 @@ +1.0.0+build.1 \ No newline at end of file diff --git a/build/build.py b/build/build.py new file mode 100644 index 0000000..b45d42e --- /dev/null +++ b/build/build.py @@ -0,0 +1,23 @@ +import os +import shutil + +import versioning + +ZIP_FILE_NAME = "blender_bake-id-mask_{version}" + +CURRENT_PATH = os.path.dirname(os.path.realpath(__file__)) + +SOURCE_PATH = os.path.join(CURRENT_PATH, "../src") +TARGET_PATH = os.path.join(CURRENT_PATH, '../dist') + +if __name__ == "__main__": + + if not os.path.isdir(TARGET_PATH): + os.mkdir(TARGET_PATH) + + currentVersion = versioning.get_version() + nextVersion = currentVersion.bump_build() + versioning.save_version(nextVersion) + + filename = os.path.join(TARGET_PATH, ZIP_FILE_NAME.format(version=nextVersion.__str__())) + shutil.make_archive(filename, 'zip', SOURCE_PATH) diff --git a/build/bump_major_version.py b/build/bump_major_version.py new file mode 100644 index 0000000..52bd8fa --- /dev/null +++ b/build/bump_major_version.py @@ -0,0 +1,12 @@ +import os + +import versioning + +CURRENT_PATH = os.path.dirname(os.path.realpath(__file__)) +CURRENT_VER_FILE = os.path.join(CURRENT_PATH, ".version") + + +if __name__ == "__main__": + currentVersion = versioning.get_version() + nextVersion = currentVersion.bump_major() + versioning.save_version(nextVersion) diff --git a/build/bump_minor.py b/build/bump_minor.py new file mode 100644 index 0000000..95053ae --- /dev/null +++ b/build/bump_minor.py @@ -0,0 +1,8 @@ +import versioning + +if __name__ == "__main__": + + currentVersion = versioning.get_version() + nextVersion = currentVersion.bump_minor() + versioning.save_version(nextVersion) + diff --git a/build/versioning.py b/build/versioning.py new file mode 100644 index 0000000..1a79540 --- /dev/null +++ b/build/versioning.py @@ -0,0 +1,19 @@ +import os + +import semver + +CURRENT_PATH = os.path.dirname(os.path.realpath(__file__)) +CURRENT_VER_FILE = os.path.join(CURRENT_PATH, ".version") + + +def get_version(): + if not os.path.isfile(CURRENT_VER_FILE): + return semver.Version.parse('1.0.0') + with open(CURRENT_VER_FILE) as f: + content = f.read() + return semver.Version.parse(content) + + +def save_version(version: semver.Version): + with open(CURRENT_VER_FILE, 'w') as f: + f.write(version.__str__())