forked from dmlc/minpy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
bump_version
executable file
·32 lines (28 loc) · 973 Bytes
/
bump_version
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
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import argparse
import os
import subprocess
import semantic_version
def main():
parser = argparse.ArgumentParser(description='Bump to new version.')
parser.add_argument('level',
help='Level of version to bump.',
choices=['major', 'minor', 'patch'])
args = parser.parse_args()
os.chdir(os.path.dirname(os.path.realpath(__file__)))
with open('VERSION') as f:
current_version = semantic_version.Version(f.readline().strip())
if args.level == 'major':
v = current_version.next_major()
elif args.level == 'minor':
v = current_version.next_minor()
elif args.level == 'patch':
v = current_version.next_patch()
else:
raise NotImplementedError('Level "{}" is not implemented.'.format(
args.level))
with open('VERSION', 'w') as f:
f.write(str(v))
if __name__ == '__main__':
main()