-
Notifications
You must be signed in to change notification settings - Fork 428
Expand file tree
/
Copy pathrelease.py
More file actions
36 lines (30 loc) · 1018 Bytes
/
release.py
File metadata and controls
36 lines (30 loc) · 1018 Bytes
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
import os
import re
def bump_version():
with open("pyproject.toml") as f:
s = f.read()
m = re.search(r'version = "(.*)\.(.*)\.(.*)"', s)
v1, v2, v3 = m.groups()
oldv = "{0}.{1}.{2}".format(v1, v2, v3)
newv = "{0}.{1}.{2}".format(v1, v2, str(int(v3) + 1))
print(f"Current version is: {oldv}, write new version, ctrl-c to exit")
ans = input(newv)
if ans:
newv = ans
s = s.replace(oldv, newv)
with open("pyproject.toml", "w") as f:
f.write(s)
return newv
def release():
v = bump_version()
ans = input("version bumped, committing?(Y/n)")
if ans in ("", "y", "yes"):
os.system("git add pyproject.toml")
os.system(f"git commit -m 'new release v{v}'")
os.system(f"git tag v{v} -m 'new release v{v}'")
ans = input("change committed, push to server?(Y/n)")
if ans in ("", "y", "yes"):
os.system("git push")
os.system("git push --tags")
if __name__ == "__main__":
release()