Skip to content

Commit 0bc3cbb

Browse files
committed
workflows/version-check: Fix check for release candidates
Reviewed By: thieta Differential Revision: https://reviews.llvm.org/D131650 (cherry picked from commit 5b108df)
1 parent 0334c1a commit 0bc3cbb

File tree

1 file changed

+18
-22
lines changed

1 file changed

+18
-22
lines changed

.github/workflows/version-check.py

Lines changed: 18 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -4,33 +4,29 @@
44
import re
55
import sys
66

7+
8+
def get_version_from_tag(tag):
9+
m = re.match('llvmorg-([0-9]+)\.([0-9]+)\.([0-9]+)(-rc[0-9]+)?$', tag)
10+
if m:
11+
if m.lastindex == 4:
12+
# We have an rc tag.
13+
return m.group(1,2,3)
14+
# We have a final release tag.
15+
return (m.group(1), m.group(2), int(m.group(3)) + 1)
16+
17+
m = re.match('llvmorg-([0-9]+)-init', tag)
18+
if m:
19+
return (int(m.group(1)) + 1, 0, 0)
20+
21+
raise Exception(f"error: Tag is not valid: {tag}")
22+
23+
724
version = sys.argv[1]
825

926
repo = Repo()
1027

1128
tag = repo.git.describe(tags = True, abbrev=0)
12-
m = re.match('llvmorg-([0-9]+)\.([0-9]+)\.([0-9]+)', tag)
13-
14-
if m:
15-
expected_major = m.group(1)
16-
expected_minor = m.group(2)
17-
expected_patch = int(m.group(3)) + 1
18-
else:
19-
# If the previous tag is llvmorg-X-init, then we should be at version X.0.0.
20-
m = re.match('llvmorg-([0-9]+)-init', tag)
21-
if not m:
22-
print("error: Tag is not valid: ", tag)
23-
sys.exit(1)
24-
expected_major = m.group(1)
25-
expected_minor = 0
26-
expected_patch = 0
27-
28-
expected_version = f"{expected_major}.{expected_minor}.{expected_patch}"
29-
30-
m = re.match("[0-9]+\.[0-9]+\.[0-9]+", version)
31-
if not m:
32-
print("error: Version is not valid: ", version)
33-
sys.exit(1)
29+
expected_version = '.'.join(get_version_from_tag(tag))
3430

3531
if version != expected_version:
3632
print("error: Expected version", expected_version, "but found version", version)

0 commit comments

Comments
 (0)