From 20e8ffc009139a94acaac9085eb8f9d1ca8bd275 Mon Sep 17 00:00:00 2001 From: Jacob Truman Date: Wed, 26 Mar 2025 19:39:00 -0600 Subject: [PATCH 1/2] XENG-8957 Set version correctly on build --- Dockerfile | 1 + pyproject.toml | 5 ++--- scripts/write-version.py | 36 ++++++++++++++++++++++++++++++++++++ 3 files changed, 39 insertions(+), 3 deletions(-) create mode 100755 scripts/write-version.py diff --git a/Dockerfile b/Dockerfile index bea64cb1..db8a5450 100644 --- a/Dockerfile +++ b/Dockerfile @@ -48,6 +48,7 @@ COPY . /buildrunner-source RUN \ cd /buildrunner-source && \ sed -i s/jaraco-classes/jaraco.classes/ requirements.txt && \ + python3 scripts/write-version.py && \ pip install . && \ rm -rf /buildrunner-source diff --git a/pyproject.toml b/pyproject.toml index 635c323a..e6b9da25 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,6 @@ build-backend = "setuptools.build_meta" [project] name = "buildrunner" -version = "3.15" description = "Docker-based build tool" readme = "README.rst" requires-python = ">=3.6" @@ -14,7 +13,7 @@ authors = [ ] urls = { "Homepage" = "https://github.com/adobe/buildrunner" } -dynamic = ["dependencies", "optional-dependencies"] +dynamic = ["version", "dependencies", "optional-dependencies"] [tool.setuptools.dynamic] dependencies = {file = ["requirements.txt"]} @@ -33,4 +32,4 @@ buildrunner-cleanup = "buildrunner.cli:clean_cache" ] [tool.setuptools.packages.find] -exclude = ["*.tests", "*.tests.*", "tests.*", "tests"] \ No newline at end of file +exclude = ["*.tests", "*.tests.*", "tests.*", "tests"] diff --git a/scripts/write-version.py b/scripts/write-version.py new file mode 100755 index 00000000..3df120d8 --- /dev/null +++ b/scripts/write-version.py @@ -0,0 +1,36 @@ +""" +Copyright 2025 Adobe +All Rights Reserved. + +NOTICE: Adobe permits you to use, modify, and distribute this file in accordance +with the terms of the Adobe license agreement accompanying it. +""" +import os +import subprocess + + +def main(): + major = 3 + minor = 15 + try: + commit_count = ( + subprocess.check_output(["git", "rev-list", "--count", "HEAD"]) + .strip() + .decode("utf-8") + ) + except Exception: + commit_count = "0" + + version_file = os.path.join( + os.path.abspath(os.path.join(__file__, os.pardir, os.pardir)), + "buildrunner", + "version.py", + ) + + version = f"{major}.{minor}.{commit_count}" + with open(version_file, "w") as version_file: + version_file.write(f'__version__ = "{version}"\n') + + +if __name__ == "__main__": + main() From b961fc8dad9cf584e23651150d6aa8f57d965418 Mon Sep 17 00:00:00 2001 From: Jacob Truman Date: Wed, 26 Mar 2025 22:58:39 -0600 Subject: [PATCH 2/2] XENG-8957 Move base version to BASE_VERSION file at root of repo --- BASE_VERSION | 1 + scripts/write-version.py | 16 +++++++++------- 2 files changed, 10 insertions(+), 7 deletions(-) create mode 100644 BASE_VERSION diff --git a/BASE_VERSION b/BASE_VERSION new file mode 100644 index 00000000..230693c3 --- /dev/null +++ b/BASE_VERSION @@ -0,0 +1 @@ +3.15 \ No newline at end of file diff --git a/scripts/write-version.py b/scripts/write-version.py index 3df120d8..85d873b3 100755 --- a/scripts/write-version.py +++ b/scripts/write-version.py @@ -10,8 +10,14 @@ def main(): - major = 3 - minor = 15 + base_dir = os.path.abspath(os.path.join(__file__, os.pardir, os.pardir)) + base_version_file = os.path.join(base_dir, "BASE_VERSION") + + with open(base_version_file, "r") as file: + base_version = file.read().strip() + + major, minor = map(int, base_version.split(".")[:2]) + try: commit_count = ( subprocess.check_output(["git", "rev-list", "--count", "HEAD"]) @@ -21,11 +27,7 @@ def main(): except Exception: commit_count = "0" - version_file = os.path.join( - os.path.abspath(os.path.join(__file__, os.pardir, os.pardir)), - "buildrunner", - "version.py", - ) + version_file = os.path.join(base_dir, "buildrunner", "version.py") version = f"{major}.{minor}.{commit_count}" with open(version_file, "w") as version_file: