-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathupdate_appcast.py
37 lines (33 loc) · 1.21 KB
/
update_appcast.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
import hashlib
import json
import sys
from pathlib import Path
def update_appcast(message):
with open ("src/info.json", "r") as f:
info = json.load(f)
version = info["version"]
release_file = Path(f"release/bob-plugin-gemini-translate.bobplugin")
assert release_file.is_file(), "Release file not exist"
with open(release_file, "rb") as f:
c = f.read()
file_hash = hashlib.sha256(c).hexdigest()
version_info = {
"version": version,
"desc": message,
"sha256": file_hash,
"url": f"https://github.com/BrianShenCC/bob-plugin-gemini-translate/releases/download/v{version}/bob-plugin-gemini-translate_v{version}.bobplugin",
"minBobVersion": "0.5.0"
}
appcast_file = Path("appcast.json")
if appcast_file.is_file():
with open(appcast_file, "r") as f:
appcast = json.load(f)
else:
appcast = dict(identifier="brian.bob-plugin-gemini-translate", versions=[])
appcast["versions"].insert(0, version_info)
with open(appcast_file, "w") as f:
json.dump(appcast, f, ensure_ascii=False, indent=2)
print(f"v{version}")
if __name__ == "__main__":
message = sys.argv[1]
update_appcast(message)