forked from mindsdb/mindsdb
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcheck_version.py
More file actions
23 lines (16 loc) · 745 Bytes
/
check_version.py
File metadata and controls
23 lines (16 loc) · 745 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import re
import sys
from mindsdb.__about__ import __version__
# PEP440: https://www.python.org/dev/peps/pep-0440/
RELEASE_PATTERN = "^\d+(\.\d+)*$" # noqa: W605
PRERELEASE_PATTERN = "^\d+(\.\d+)*(a|b|rc)\d+$" # noqa: W605
version_str = sys.argv[1].replace('v', '')
is_prerelease = sys.argv[2] == "true"
if is_prerelease:
if re.match(PRERELEASE_PATTERN, version_str) is None:
raise Exception("Invalid prerelease version: %s" % version_str)
elif re.match(RELEASE_PATTERN, version_str) is None:
raise Exception("Invalid release version: %s" % version_str)
if version_str != __version__:
raise Exception("Version mismatch between __about__.py and release tag: %s != %s" % (version_str, __version__))
print(version_str)