-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathpush_minor.py
53 lines (40 loc) · 1.55 KB
/
push_minor.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
# run with python push_minor.py
import re
import subprocess
import os
# get branch name
branch = subprocess.check_output(['git', 'branch', '--show-current']).decode().strip()
# merge master to avoid merge conflicts later
print('===== Fetch master, then merge it ====')
os.system('git fetch origin master')
os.system('git merge origin/master')
print("=== Update version number ===")
# increment version number
with open('src/resipy/Project.py', 'r') as f:
x = f.read()
out = re.findall("(\d+\.\d+\.\d+)", x)
print(out)
version_old = out[0]
version = version_old.split('.')
version[-1] = str(int(version[-1])+1)
version_new = '.'.join(version)
with open('src/resipy/Project.py', 'w') as f:
f.write(x.replace(version_old, version_new))
with open('src/setup.py', 'r') as f:
x = f.read()
with open('src/setup.py', 'w') as f:
f.write(x.replace(version_old, version_new))
with open('src/Version.details', 'r') as f:
x = f.read()
with open('src/Version.details', 'w') as f:
f.write(x.replace(version_old, version_new).replace(','.join(version_old.split('.')), ','.join(version_new.split('.'))))
# commit version increase
os.system('git add src/resipy/Project.py')
os.system('git add src/setup.py')
os.system('git add src/Version.details')
os.system(f'git commit -m "Update to v{version_new}"')
print("=== Create tag and merge request ===")
# create tag
os.system(f'git tag v{version_new}')
# push and create merge request
os.system(f'git push --set-upstream origin {branch} -o merge_request.create -o merge_request.title="v{version_new}" tag v{version_new}')