forked from PiBrewing/craftbeerpi4-ui
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrelease.py
52 lines (40 loc) · 1.35 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
import subprocess
import click
import re
@click.group()
def main():
pass
@click.command()
@click.option('-m', prompt='Commit Message')
def commit(m):
file = "./cbpi4gui/version.py"
with open(file) as reader:
match = re.search('.*\"(.*)\"', reader.readline())
major, minor, patch = match.group(1).split(".")
patch = int(patch)
patch += 1
new_version = "__version__ = \"{}.{}.{}\"".format(major,minor,patch)
with open(file,'w',encoding = 'utf-8') as file:
file.write(new_version)
subprocess.run(["npm", "run", "build"], cwd="./cbpi4gui")
subprocess.run(["git", "add", "-A"])
subprocess.run(["git", "commit", "-m", "\"{}\"".format(m)])
subprocess.run(["git", "push"])
@click.command()
def build():
subprocess.run(["npm", "run", "build"], cwd="./cbpi4gui")
subprocess.run(["python3", "setup.py", "sdist"])
@click.command()
def release():
subprocess.run(["python3", "setup.py", "sdist"])
file = "./cbpi4gui/version.py"
with open(file) as reader:
match = re.search('.*\"(.*)\"', reader.readline())
version = match.group(1)
path = "dist/cbpi4ui-{}.tar.gz".format(version)
subprocess.run(["twine", "upload", path])
main.add_command(commit)
main.add_command(release)
main.add_command(build)
if __name__ == '__main__':
main()