-
Notifications
You must be signed in to change notification settings - Fork 15
/
next_release.py
62 lines (48 loc) · 1.38 KB
/
next_release.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
51
52
53
54
55
56
57
58
59
60
61
import re
import os
def version():
v="NA"
with open("barnaba/_version.py") as f:
for line in f:
if re.match("^__version__ *= *",line):
v=re.sub('^__version__ *= *"',"",line.strip())
v=re.sub('".*',"",v)
return v
def confirm():
cont=True
while cont:
response=input("Confirm (yes/no)?")
if re.match("[Yy][Ee][Ss]",response):
cont=False
elif re.match("[Nn][Oo]",response):
quit()
else:
pass
__version__=version()
print("Current version:",__version__)
new_version=re.sub("[0-9]*$","",__version__) + str(int(re.sub("^.*\.","",__version__))+1)
response=input("New version (default " + new_version + "):")
if len(response)>0:
new_version=response
print("New version "+new_version)
confirm()
lines=[]
with open("barnaba/_version.py") as f:
for line in f:
line=re.sub("^ *__version__ *=.*$",'__version__ = "' + new_version + '"',line)
lines.append(line)
with open("barnaba/_version.py","w") as f:
for line in lines:
print(line,file=f,end='')
cmd=[
'git add barnaba/_version.py',
'git commit -m "Version ' + new_version + '"',
'git tag ' + new_version,
'git push origin master ' + new_version
]
print("Will now execute the following commands:")
for c in cmd:
print(" " + c)
confirm()
for c in cmd:
os.system(c)