-
Notifications
You must be signed in to change notification settings - Fork 0
/
bump_version.py
executable file
·34 lines (26 loc) · 1.04 KB
/
bump_version.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#!/usr/bin/env python3
import argparse
import semantic_version
def main():
parser = argparse.ArgumentParser(description=
'Bumps the semantic version of this package.')
parser.add_argument('--mode', type=str, required=True, default="patch",
help='Whether to bump (major, minor or patch) number (default: patch)')
args = parser.parse_args()
mode = args.mode
if not mode:
raise ValueError("User must specify which semantic version mode to use")
version = open('VERSION').read().strip()
oldsemver = semantic_version.Version(version)
if mode == "major":
newsemver = oldsemver.next_major()
elif mode == "minor":
newsemver = oldsemver.next_minor()
elif mode == "patch":
newsemver = oldsemver.next_patch()
else:
raise ValueError("Unrecognised semantic version mode")
print("Updating QuaTradis version from", oldsemver, "to", newsemver)
open('VERSION', 'w').write(str(newsemver))
if __name__ == '__main__':
main()