Skip to content

Commit 23fcd95

Browse files
authored
Merge pull request #194 from jacobtruman/XENG-8985
XENG-8957 Set version correctly on build
2 parents 6a8c1f5 + b961fc8 commit 23fcd95

File tree

4 files changed

+42
-3
lines changed

4 files changed

+42
-3
lines changed

BASE_VERSION

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
3.15

Dockerfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ COPY . /buildrunner-source
4848
RUN \
4949
cd /buildrunner-source && \
5050
sed -i s/jaraco-classes/jaraco.classes/ requirements.txt && \
51+
python3 scripts/write-version.py && \
5152
pip install . && \
5253
rm -rf /buildrunner-source
5354

pyproject.toml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ build-backend = "setuptools.build_meta"
44

55
[project]
66
name = "buildrunner"
7-
version = "3.15"
87
description = "Docker-based build tool"
98
readme = "README.rst"
109
requires-python = ">=3.6"
@@ -14,7 +13,7 @@ authors = [
1413
]
1514
urls = { "Homepage" = "https://github.com/adobe/buildrunner" }
1615

17-
dynamic = ["dependencies", "optional-dependencies"]
16+
dynamic = ["version", "dependencies", "optional-dependencies"]
1817

1918
[tool.setuptools.dynamic]
2019
dependencies = {file = ["requirements.txt"]}
@@ -33,4 +32,4 @@ buildrunner-cleanup = "buildrunner.cli:clean_cache"
3332
]
3433

3534
[tool.setuptools.packages.find]
36-
exclude = ["*.tests", "*.tests.*", "tests.*", "tests"]
35+
exclude = ["*.tests", "*.tests.*", "tests.*", "tests"]

scripts/write-version.py

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
"""
2+
Copyright 2025 Adobe
3+
All Rights Reserved.
4+
5+
NOTICE: Adobe permits you to use, modify, and distribute this file in accordance
6+
with the terms of the Adobe license agreement accompanying it.
7+
"""
8+
import os
9+
import subprocess
10+
11+
12+
def main():
13+
base_dir = os.path.abspath(os.path.join(__file__, os.pardir, os.pardir))
14+
base_version_file = os.path.join(base_dir, "BASE_VERSION")
15+
16+
with open(base_version_file, "r") as file:
17+
base_version = file.read().strip()
18+
19+
major, minor = map(int, base_version.split(".")[:2])
20+
21+
try:
22+
commit_count = (
23+
subprocess.check_output(["git", "rev-list", "--count", "HEAD"])
24+
.strip()
25+
.decode("utf-8")
26+
)
27+
except Exception:
28+
commit_count = "0"
29+
30+
version_file = os.path.join(base_dir, "buildrunner", "version.py")
31+
32+
version = f"{major}.{minor}.{commit_count}"
33+
with open(version_file, "w") as version_file:
34+
version_file.write(f'__version__ = "{version}"\n')
35+
36+
37+
if __name__ == "__main__":
38+
main()

0 commit comments

Comments
 (0)