Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / .github / workflows / version-check.py
blob7f805f304e3d76f8103690c1f8671aac88ae6021
1 #!/usr/bin/python3
3 from git import Repo
4 import re
5 import sys
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), str(int(m.group(3)) + 1))
17 m = re.match("llvmorg-([0-9]+)-init", tag)
18 if m:
19 return (m.group(1), "0", "0")
21 raise Exception(f"error: Tag is not valid: {tag}")
24 version = sys.argv[1]
26 repo = Repo()
28 tag = repo.git.describe(tags=True, abbrev=0)
29 expected_version = ".".join(get_version_from_tag(tag))
31 if version != expected_version:
32 print("error: Expected version", expected_version, "but found version", version)
33 sys.exit(1)
35 print("Versions match:", version, expected_version)
36 sys.exit(0)