-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathmake_release.py
79 lines (59 loc) · 1.94 KB
/
make_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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
import json
import shutil
import os
import sys
import subprocess
from zipfile import ZipFile, ZIP_DEFLATED
from tarfile import TarFile
from pathlib import Path
def get_version():
fn = "package.json"
with open(fn, "r") as f:
data = json.loads(f.read())
return data['version']
def main():
if sys.platform == "win32":
make_win32()
elif sys.platform == "linux":
make_linux()
elif sys.platform == "darwin":
make_darwin()
else:
print("OS not supported")
def make_linux():
if os.path.isdir("dist"):
shutil.rmtree("dist")
subprocess.Popen(["npm", "run", "build"]).wait()
for cache in Path("zp_server").rglob("__pycache__"):
shutil.rmtree(cache)
os.mkdir("dist")
with TarFile.open(f"dist/ZeppPlayer_v{get_version()}_linux.tar.gz", "x:gz") as tar:
tar.add("package.json")
tar.add("package-lock.json")
tar.add("start.sh")
for dirname in ["app", "projects/demo", "zp_server"]:
tar.add(dirname, recursive=True)
def make_darwin():
if os.path.isdir("dist"):
shutil.rmtree("dist")
subprocess.Popen(["npm", "run", "build"]).wait()
subprocess.Popen(["pyinstaller", 'ZeppPlayer.osx.spec']).wait()
with TarFile.open(f"dist/ZeppPlayer_v{get_version()}_macos.tar.gz", "x:gz") as tar:
tar.add("dist/ZeppPlayer.app", recursive=True)
def make_win32():
if os.path.isdir("dist"):
shutil.rmtree("dist")
spec_file = "ZeppPlayer.win32.spec"
dist_file = "ZeppPlayer.exe"
subprocess.Popen(["npm.cmd", "run", "build"]).wait()
subprocess.Popen([r"venv\Scripts\pyinstaller.exe", spec_file]).wait()
with ZipFile(f"dist/ZeppPlayer_v{get_version()}_win32.zip", "w", ZIP_DEFLATED) as zip:
zip.write("package.json")
zip.write("package-lock.json")
zip.write(f"dist/{dist_file}", dist_file)
for dirname in ["app", "projects/demo"]:
p = Path(dirname)
for f in p.rglob("**/*"):
fn = str(f)[len(str(p))+1:]
zip.write(str(f), dirname + "/" + fn)
main()