-
-
Notifications
You must be signed in to change notification settings - Fork 3
/
3.make_release.py
69 lines (51 loc) · 1.7 KB
/
3.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
import os
import requests
from requests.packages.urllib3.exceptions import InsecureRequestWarning
from settings import PATCH_FOLDER, LANG, TRANS_RELEASE_FOLDER, BASE_FOLDER
# disable warning if we use proxy
requests.packages.urllib3.disable_warnings(InsecureRequestWarning)
COMPRESS_TOOL = '7z'
COMPRESS_LEVEL = 9
def make_patch():
# 打zip包
# make zip
new_name = f'jackett-{LANG}-patch.zip'
print('new_name', new_name)
os.system(f'rm -f {new_name}')
os.chdir(TRANS_RELEASE_FOLDER)
if COMPRESS_TOOL == '7z':
cmd = f'7z a {new_name} -r {PATCH_FOLDER}/*'
else:
cmd = f'zip -{COMPRESS_LEVEL} -r {new_name} {PATCH_FOLDER}/*'
print(cmd)
os.system(cmd)
def make_release_package():
# 应用补丁
# apply patch
cmd = f'cp -rf {PATCH_FOLDER}* "{BASE_FOLDER}/Jackett/"'
print('cmd', cmd)
os.system(cmd)
# 打zip包
# make zip
new_name = f'Jackett-cn.Binaries.Windows.zip'
if COMPRESS_TOOL == '7z':
cmd = f'7z a {new_name} -r {BASE_FOLDER}/Jackett/*'
else:
cmd = f'zip -{COMPRESS_LEVEL} -r {new_name} {BASE_FOLDER}/Jackett/*'
print(cmd)
os.system(cmd)
if __name__ == '__main__':
if 'GITHUB_ACTIONS' in os.environ:
print('当前在Github Actions中运行')
else:
print('当前在本地电脑上运行')
a = input(f'Delete folder {TRANS_RELEASE_FOLDER}, continue?(y)')
if a not in ['y', ]:
exit()
os.system(f'rm -rf {TRANS_RELEASE_FOLDER}')
os.makedirs(f'{TRANS_RELEASE_FOLDER}')
os.chdir(TRANS_RELEASE_FOLDER)
make_patch()
make_release_package()
if 'GITHUB_ACTIONS' not in os.environ:
os.system(f'xdg-open {TRANS_RELEASE_FOLDER}')