-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbin_version.py
executable file
·50 lines (49 loc) · 1.16 KB
/
bin_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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#!/usr/bin/env python3
import argparse
import subprocess
import re
parser = argparse.ArgumentParser()
parser.add_argument('version')
parser.add_argument('-f', '--force', action='store_true')
args = parser.parse_args()
if not args.force and subprocess.call(['git', 'diff-index', '--quiet', 'HEAD']) != 0: # noqa
raise RuntimeError('Working directory must be clean.')
if not re.match('\\d+\\.\\d+\\.\\d+', args.version):
args.error('version must be in the format N.N.N')
subprocess.check_call([
'mvn',
'versions:set',
'-DnewVersion={}'.format(args.version),
'-DgenerateBackupPoms=false',
])
subprocess.check_call([
'sed',
'-e', 's/\\(Version \\|merman-\\|v\\)[[:digit:]]\\+\\.[[:digit:]]\\+\\.[[:digit:]]\\+/\\1{}/g'.format( # noqa
args.version
),
'-i',
'readme.md',
])
subprocess.call([
'git',
'commit',
'-a',
'-m', 'VERSION {}'.format(args.version),
])
subprocess.check_call([
'git',
'tag',
'-a', 'v{}'.format(args.version),
'-m', 'v{}'.format(args.version),
'-f',
])
subprocess.check_call([
'git',
'push',
])
subprocess.check_call([
'git',
'push',
'--tags',
'-f',
])