summaryrefslogtreecommitdiff
path: root/.github/workflows
diff options
context:
space:
mode:
authorTom Stellard <tstellar@redhat.com>2022-08-19 21:51:00 -0700
committerTom Stellard <tstellar@redhat.com>2022-08-19 21:51:04 -0700
commit5b108dfc159a461c10bba1fd1f05308bf57dcd25 (patch)
tree6ca68815d07c5eaed2a30f1a96bebd48dc4c813a /.github/workflows
parentc38bc421b1268ca371cdbb54e470d758968ce67a (diff)
downloadllvm-5b108dfc159a461c10bba1fd1f05308bf57dcd25.tar.gz
workflows/version-check: Fix check for release candidates
Reviewed By: thieta Differential Revision: https://reviews.llvm.org/D131650
Diffstat (limited to '.github/workflows')
-rwxr-xr-x.github/workflows/version-check.py40
1 files changed, 18 insertions, 22 deletions
diff --git a/.github/workflows/version-check.py b/.github/workflows/version-check.py
index 11591312c281..f2cef9f86427 100755
--- a/.github/workflows/version-check.py
+++ b/.github/workflows/version-check.py
@@ -4,33 +4,29 @@ from git import Repo
import re
import sys
+
+def get_version_from_tag(tag):
+ m = re.match('llvmorg-([0-9]+)\.([0-9]+)\.([0-9]+)(-rc[0-9]+)?$', tag)
+ if m:
+ if m.lastindex == 4:
+ # We have an rc tag.
+ return m.group(1,2,3)
+ # We have a final release tag.
+ return (m.group(1), m.group(2), int(m.group(3)) + 1)
+
+ m = re.match('llvmorg-([0-9]+)-init', tag)
+ if m:
+ return (int(m.group(1)) + 1, 0, 0)
+
+ raise Exception(f"error: Tag is not valid: {tag}")
+
+
version = sys.argv[1]
repo = Repo()
tag = repo.git.describe(tags = True, abbrev=0)
-m = re.match('llvmorg-([0-9]+)\.([0-9]+)\.([0-9]+)', tag)
-
-if m:
- expected_major = m.group(1)
- expected_minor = m.group(2)
- expected_patch = int(m.group(3)) + 1
-else:
- # If the previous tag is llvmorg-X-init, then we should be at version X.0.0.
- m = re.match('llvmorg-([0-9]+)-init', tag)
- if not m:
- print("error: Tag is not valid: ", tag)
- sys.exit(1)
- expected_major = m.group(1)
- expected_minor = 0
- expected_patch = 0
-
-expected_version = f"{expected_major}.{expected_minor}.{expected_patch}"
-
-m = re.match("[0-9]+\.[0-9]+\.[0-9]+", version)
-if not m:
- print("error: Version is not valid: ", version)
- sys.exit(1)
+expected_version = '.'.join(get_version_from_tag(tag))
if version != expected_version:
print("error: Expected version", expected_version, "but found version", version)