Skip to content

Commit d58dc8f

Browse files
author
Jacob Truman
committed
XENG-8957 Set version correctly on build
1 parent 6a8c1f5 commit d58dc8f

File tree

3 files changed

+35
-3
lines changed

3 files changed

+35
-3
lines changed

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: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
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+
def main():
12+
major = 3
13+
minor = 15
14+
try:
15+
commit_count = subprocess.check_output(
16+
['git', 'rev-list', '--count', 'HEAD']
17+
).strip().decode('utf-8')
18+
except Exception:
19+
commit_count = '0'
20+
21+
version_file = os.path.join(
22+
os.path.abspath(os.path.join(__file__, os.pardir, os.pardir)),
23+
"buildrunner",
24+
"version.py"
25+
)
26+
27+
version = f"{major}.{minor}.{commit_count}"
28+
with open(version_file, 'w') as version_file:
29+
version_file.write(f'__version__ = "{version}"\n')
30+
31+
if __name__ == "__main__":
32+
main()

0 commit comments

Comments
 (0)