Skip to content

Commit a16bde0

Browse files
committed
ci: grab default release tag from Git commit time
This should make the datetime strings consistent across all platforms.
1 parent 7abe8bb commit a16bde0

File tree

5 files changed

+29
-11
lines changed

5 files changed

+29
-11
lines changed

.github/workflows/linux.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,8 +136,6 @@ jobs:
136136
137137
- name: Build
138138
run: |
139-
export PYBUILD_RELEASE_TAG=$(git log -n 1 --date=format:%Y%m%dT%H%M --pretty=format:%ad)
140-
141139
if [ "${{ matrix.triple }}" = "x86_64-unknown-linux-musl" ]; then
142140
EXTRA_ARGS=--libressl
143141
else

.github/workflows/macos.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,6 @@ jobs:
118118
119119
- name: Build
120120
run: |
121-
export PYBUILD_RELEASE_TAG=$(git log -n 1 --date=format:%Y%m%dT%H%M --pretty=format:%ad)
122121
./build-macos.py --python ${{ matrix.py }} --optimizations ${{ matrix.optimizations }}
123122
124123
- name: Stop sccache

cpython-unix/build-main.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,16 @@
44
# file, You can obtain one at https://mozilla.org/MPL/2.0/.
55

66
import argparse
7-
import datetime
87
import os
98
import pathlib
109
import subprocess
1110
import sys
1211

1312
from pythonbuild.downloads import DOWNLOADS
14-
from pythonbuild.utils import compress_python_archive
13+
from pythonbuild.utils import (
14+
compress_python_archive,
15+
release_tag_from_git,
16+
)
1517

1618
ROOT = pathlib.Path(os.path.abspath(__file__)).parent.parent
1719
BUILD = ROOT / "build"
@@ -91,8 +93,7 @@ def main():
9193
if "PYBUILD_RELEASE_TAG" in os.environ:
9294
release_tag = os.environ["PYBUILD_RELEASE_TAG"]
9395
else:
94-
now = datetime.datetime.utcnow()
95-
release_tag = now.strftime("%Y%m%dT%H%M")
96+
release_tag = release_tag_from_git()
9697

9798
archive_components = [
9899
"cpython-%s" % entry["version"],

cpython-windows/build.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55

66
import argparse
77
import concurrent.futures
8-
import datetime
98
import json
109
import os
1110
import pathlib
@@ -25,6 +24,7 @@
2524
extract_tar_to_directory,
2625
extract_zip_to_directory,
2726
compress_python_archive,
27+
release_tag_from_git,
2828
validate_python_json,
2929
)
3030

@@ -2322,8 +2322,6 @@ def main():
23222322
print("--sh required when building Python 3.8+")
23232323
return 1
23242324

2325-
now = datetime.datetime.utcnow()
2326-
23272325
log_path = BUILD / "build.log"
23282326

23292327
with log_path.open("wb") as log_fh:
@@ -2365,8 +2363,13 @@ def main():
23652363
libffi_archive=libffi_archive,
23662364
)
23672365

2366+
if "PYBUILD_RELEASE_TAG" in os.environ:
2367+
release_tag = os.environ["PYBUILD_RELEASE_TAG"]
2368+
else:
2369+
release_tag = release_tag_from_git()
2370+
23682371
compress_python_archive(
2369-
tar_path, DIST, "%s-%s" % (tar_path.stem, now.strftime("%Y%m%dT%H%M")),
2372+
tar_path, DIST, "%s-%s" % (tar_path.stem, release_tag),
23702373
)
23712374

23722375

pythonbuild/utils.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,23 @@
1919
from .logging import log
2020

2121

22+
def release_tag_from_git():
23+
return (
24+
subprocess.check_output(
25+
[
26+
"git",
27+
"log",
28+
"-n",
29+
"1",
30+
"--date=format:%Y%m%dT%H%M",
31+
"--pretty=format:%ad",
32+
]
33+
)
34+
.strip()
35+
.decode("ascii")
36+
)
37+
38+
2239
def hash_path(p: pathlib.Path):
2340
h = hashlib.sha256()
2441

0 commit comments

Comments
 (0)