文件
dayu-color/Packaging/publish_release.py
T

42 行
2.3 KiB
Python
原始文件 Blame 文件历史

此文件含有模棱两可的 Unicode 字符
此文件含有可能会与其他字符混淆的 Unicode 字符。 如果您是想特意这样的,可以安全地忽略该警告。 使用 Escape 按钮显示他们。
#!/usr/bin/env python3
"""Upload the exact verified package recorded by an existing release tag."""
import argparse
import json
from pathlib import Path
import subprocess
ROOT = Path(__file__).resolve().parent.parent
def main():
parser = argparse.ArgumentParser(description=__doc__)
parser.add_argument("--tag", required=True)
parser.add_argument("--notes", required=True, type=Path)
parser.add_argument("--pkg-forge-repo", type=Path,
default=Path.home() / "Documents/dayu-git/repositories/pkg-forge")
args = parser.parse_args()
report = json.loads((ROOT / "verification/Package.json").read_text())
assert report["pass"] and not report["testUnsigned"] and report["notarization"]["status"] == "Accepted"
tag_report = json.loads(subprocess.check_output(
["git", "show", args.tag + ":verification/Package.json"], cwd=ROOT, text=True))
for key in ["sha256", "bytes", "appCompiledSource", "appBuild"]:
assert tag_report[key] == report[key], "所选标签与当前已验包记录不一致:" + key
app = report["resources"][0]
assert app["bundleID"] == "com.dayu.color" and app["version"] == tag_report["resources"][0]["version"]
package = Path(report["package"])
signature = subprocess.check_output(["pkgutil", "--check-signature", str(package)], text=True)
assert "Developer ID Installer: zhong luo (B3W25FX5H5)" in signature
subprocess.run(["xcrun", "stapler", "validate", str(package)], check=True, capture_output=True)
subprocess.run(["spctl", "--assess", "--type", "install", str(package)], check=True, capture_output=True)
commit = subprocess.check_output(["git", "rev-parse", args.tag + "^{commit}"], cwd=ROOT, text=True).strip()
helper = args.pkg_forge_repo / "skills/pkg-forge/scripts/publish_release.py"
subprocess.run(["python3", str(helper), "--repository", "dayu/dayu-color", "--repo-root", str(ROOT),
"--tag", args.tag, "--commit", commit, "--title", "大鱼调色 " + app["version"] + "(" + app["build"] + ")",
"--body-file", str(args.notes.resolve()), "--asset", str(package), "--sha256", report["sha256"],
"--bytes", str(report["bytes"]), "--account", "dayu",
"--report", str(ROOT / "verification/Release.json")], check=True)
if __name__ == "__main__":
main()