[PATCH] D131650: workflows/version-check: Fix check for release candidates

Tom Stellard via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Aug 12 01:38:10 PDT 2022


tstellar updated this revision to Diff 452104.
tstellar added a comment.

Handle release candidate tags for any release.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D131650/new/

https://reviews.llvm.org/D131650

Files:
  .github/workflows/version-check.py


Index: .github/workflows/version-check.py
===================================================================
--- .github/workflows/version-check.py
+++ .github/workflows/version-check.py
@@ -4,33 +4,29 @@
 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)


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D131650.452104.patch
Type: text/x-patch
Size: 1674 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220812/1fd83a9c/attachment.bin>


More information about the llvm-commits mailing list