Skip to content

Commit 61ee5d5

Browse files
authored
Merge pull request #3870 from regro/robust-next-tag
fix: find the last version tag as the max to fix a race condition
2 parents 953a6f0 + 2b8a9a0 commit 61ee5d5

File tree

2 files changed

+19
-4
lines changed

2 files changed

+19
-4
lines changed

.github/workflows/release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ jobs:
4242
id: version
4343
if: ${{ ! env.CI_SKIP }}
4444
run: |
45-
echo "current version: "$(git tag --sort=committerdate | tail -1)
45+
echo "recent version tags: "$(git tag --sort=committerdate | tail -4)
4646
NEXT=$(python autotick-bot/compute_next_version.py)
4747
echo "next version: ${NEXT}"
4848
echo "NEXT=${NEXT}" >> "$GITHUB_OUTPUT"

autotick-bot/compute_next_version.py

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
import subprocess
33
import sys
44

5+
from conda.models.version import VersionOrder
6+
57
# get the current date for tagging below
68
now = datetime.datetime.utcnow()
79

@@ -18,15 +20,28 @@
1820
else:
1921
# we have a tag so bump
2022
curr_version = None
23+
curr_version_line = None
2124
for line in res.stdout.splitlines():
2225
line = line.strip()
2326
if line:
24-
curr_version = line
27+
try:
28+
_version = VersionOrder(line)
29+
except Exception:
30+
print(
31+
f"skipping tag that is not a version: {line}",
32+
file=sys.stderr,
33+
flush=True,
34+
)
35+
continue
36+
37+
if curr_version is None or _version > curr_version:
38+
curr_version = _version
39+
curr_version_line = line
2540
assert curr_version is not None
26-
print("found current version: %s" % line, file=sys.stderr, flush=True)
41+
print(f"found current version: {curr_version_line}", file=sys.stderr, flush=True)
2742

2843
# figure out if we bump the major, minor or patch version
29-
major_minor, patch = curr_version.rsplit(".", 1)
44+
major_minor, patch = curr_version_line.rsplit(".", 1)
3045
now_major_minor = f"{now.year}.{now.month}"
3146
if major_minor == now_major_minor:
3247
new_version = f"{major_minor}.{int(patch) + 1}"

0 commit comments

Comments
 (0)