-
Notifications
You must be signed in to change notification settings - Fork 83
/
release.py
60 lines (47 loc) · 1.6 KB
/
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
import code
import subprocess
import click
import re
@click.group()
def main():
pass
@click.command()
@click.option('-m', prompt='Commit Message')
def commit(m):
new_content = []
file = "./cbpi/__init__.py"
with open(file) as reader:
match = re.search('.*\"(.*)\"', reader.readline())
codename = reader.readline()
try:
major, minor, patch, build = match.group(1).split(".")
except:
major, minor, patch = match.group(1).split(".")
patch = int(patch)
patch += 1
new_content.append("__version__ = \"{}.{}.{}\"".format(major,minor,patch))
new_content.append(codename)
with open(file,'w',encoding = 'utf-8') as file:
print("New Version {}.{}.{}".format(major,minor,patch))
file.writelines("%s\n" % i for i in new_content)
subprocess.run(["git", "add", "-A"])
subprocess.run(["git", "commit", "-m", "\"{}\"".format(m)])
subprocess.run(["git", "push"])
@click.command()
def build():
subprocess.run(["python3", "setup.py", "sdist"])
@click.command()
def release():
subprocess.run(["python3", "setup.py", "sdist"])
file = "./cbpi/__init__.py"
with open(file) as reader:
match = re.search('.*\"(.*)\"', reader.readline())
version = match.group(1)
path = "dist/cbpi-{}.tar.gz".format(version)
print("Uploading File {} ".format(path))
subprocess.run(["twine", "upload", path])
main.add_command(commit)
main.add_command(release)
main.add_command(build)
if __name__ == '__main__':
main()