Skip to content

Commit

Permalink
优化插件性能
Browse files Browse the repository at this point in the history
  • Loading branch information
akl7777777 committed Mar 21, 2023
1 parent 5381462 commit 208203e
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions scripts/update_appcast.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,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-akl-caiyunxiaoyi-free-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/akl7777777/bob-plugin-akl-caiyunxiaoyi-free-translate/releases/download/v{version}/bob-plugin-akl-caiyunxiaoyi-free-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="com.akl.bob-plugin-akl-caiyunxiaoyi-free-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)

0 comments on commit 208203e

Please sign in to comment.