-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathnew_release.py
More file actions
executable file
·79 lines (60 loc) · 1.89 KB
/
Copy pathnew_release.py
File metadata and controls
executable file
·79 lines (60 loc) · 1.89 KB
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#!/usr/bin/env python2
from subprocess import call
from ansible_bundle import __version__
import argparse
import os
def get_arguments():
parser = argparse.ArgumentParser()
parser.add_argument('--patch', action='store_true', default=True)
parser.add_argument('--major', action='store_true', default=False)
parser.add_argument('--minor', action='store_true', default=False)
return parser.parse_args()
def get_version():
return __version__.split('.')
def increase(string):
return str(int(string) + 1)
def increase_patch():
major, minor, patch = get_version()
patch = increase(patch)
return '%s.%s.%s' % (major, minor, patch)
def increase_minor():
major, minor, patch = get_version()
minor = increase(minor)
return '%s.%s.0' % (major, minor)
def increase_major():
major, minor, patch = get_version()
major = increase(major)
return '%s.0.0' % major
def new_version(version):
filename = os.path.join('ansible_bundle', '__init__.py')
contents = list()
with open(filename, 'r') as fn:
contents = fn.read().split('\n')
with open(filename, 'w') as fn:
for line in contents:
if len(line) > 0:
if '__version__' in line:
fn.write('__version__ = \'%s\'' % version)
else:
fn.write(line)
fn.write('\n')
def main():
args = get_arguments()
if args.major:
version = increase_major()
elif args.minor:
version = increase_minor()
elif args.patch:
version = increase_patch()
new_version(version)
script = (
['git', 'commit', '-am', 'New version %s' % version],
['git', 'push'],
['git', 'tag', version],
['git', 'push', '--tags'],
['python', 'setup.py', 'sdist', 'upload']
)
for line in script:
call(line)
if __name__ == '__main__':
main()