-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpublish.py
60 lines (53 loc) · 1.42 KB
/
publish.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 datetime
import os
import json
import shutil
TIMESTAMP = datetime.datetime.now().strftime("%Y-%m-%d")
# extract version from package.json
NAME = None
VERSION = None
with open("package.json") as file:
data = json.load(file)
NAME = data["name"]
VERSION = data["version"]
if NAME is None or VERSION is None:
raise Exception("name or version not found in package.json")
# find the APK
APK_FOLDER = "android/app/release"
APK_PATH = None
for file in os.listdir(APK_FOLDER):
if file.endswith(".apk"):
APK_PATH = os.path.join(APK_FOLDER, file)
break
if APK_PATH is None:
raise Exception("APK not found in " + APK_FOLDER)
# prepare publish directory
PUBLISH_FOLDER = "publish"
RELEASE_FOLDER = os.path.join(PUBLISH_FOLDER, VERSION)
os.makedirs(RELEASE_FOLDER, exist_ok=True)
# copy APK to release directory
shutil.copy(APK_PATH, os.path.join(RELEASE_FOLDER, f"{NAME}-{VERSION}.apk"))
# create meta file
META = {
"name": NAME,
"version": VERSION,
"date": TIMESTAMP,
"changelog": "",
"android": {
"link": "",
"mirror": "",
},
"ios": {
"link": "",
"mirror": "",
},
}
with open(os.path.join(RELEASE_FOLDER, "meta.json"), "w") as file:
json.dump(META, file, indent=4)
# update global meta file
META = {
"name": NAME,
"latest": VERSION,
}
with open(os.path.join(PUBLISH_FOLDER, "meta.json"), "w") as file:
json.dump(META, file, indent=4)