-
Notifications
You must be signed in to change notification settings - Fork 4
/
bump_version.py
33 lines (25 loc) · 1.02 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
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 Albatradis version from", oldsemver, "to", newsemver)
open('VERSION', 'w').write(str(newsemver))
if __name__ == '__main__':
main()