Skip to content

Commit fdedeca

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

File tree

3 files changed

+28
-3
lines changed

3 files changed

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

0 commit comments

Comments
 (0)