History

feat: add beta update channel

Peter Steinberger committed 9 months ago

Commit bb6f00f1 parent 20b79ee7 files · +169 −1Browse files

Showing the changes to Scripts (1 of 7 files). Show all

Unified · Split

Scripts/make_appcast.sh+34−0
@@ -6,6 +6,7 @@ ZIP=${1:? · 5 unmodified lines
6"Usage: $0 CodexBar-<ver>.zip"}6"Usage: $0 CodexBar-<ver>.zip"}
7FEED_URL=${2:-"https://raw.githubusercontent.com/steipete/CodexBar/main/appcast.xml"}7FEED_URL=${2:-"https://raw.githubusercontent.com/steipete/CodexBar/main/appcast.xml"}
8PRIVATE_KEY_FILE=${SPARKLE_PRIVATE_KEY_FILE:-}8PRIVATE_KEY_FILE=${SPARKLE_PRIVATE_KEY_FILE:-}
9SPARKLE_CHANNEL=${SPARKLE_CHANNEL:-}
9if [[ -z "$PRIVATE_KEY_FILE" ]]; then10if [[ -z "$PRIVATE_KEY_FILE" ]]; then
10 echo "Set SPARKLE_PRIVATE_KEY_FILE to your ed25519 private key (Sparkle)." >&211 echo "Set SPARKLE_PRIVATE_KEY_FILE to your ed25519 private key (Sparkle)." >&2
11 exit 112 exit 1
@@ -69,6 +70,39 @@ generate_appcast \ · 57 unmodified lines
69 "$WORK_DIR"70 "$WORK_DIR"
70popd >/dev/null71popd >/dev/null
71 72
73if [[ -n "$SPARKLE_CHANNEL" ]]; then
74 python3 - "$WORK_DIR/appcast.xml" "$VERSION" "$SPARKLE_CHANNEL" <<'PY'
75import re
76import sys
77
78path, version, channel = sys.argv[1], sys.argv[2], sys.argv[3]
79with open(path, "r", encoding="utf-8") as handle:
80 lines = handle.read().splitlines()
81
82target = f"<sparkle:shortVersionString>{version}</sparkle:shortVersionString>"
83try:
84 index = next(i for i, line in enumerate(lines) if target in line)
85except StopIteration as exc:
86 raise SystemExit(f"Could not find {target} in {path}") from exc
87
88for j in range(index, -1, -1):
89 if "<item" in lines[j]:
90 line = lines[j]
91 if "sparkle:channel" in line:
92 line = re.sub(r'sparkle:channel="[^"]*"', f'sparkle:channel="{channel}"', line)
93 else:
94 line = line.replace("<item", f'<item sparkle:channel="{channel}"', 1)
95 lines[j] = line
96 break
97else:
98 raise SystemExit(f"Could not find <item> for version {version} in {path}")
99
100with open(path, "w", encoding="utf-8") as handle:
101 handle.write("\n".join(lines) + "\n")
102PY
103 echo "Tagged ${VERSION} with sparkle:channel=\"${SPARKLE_CHANNEL}\""
104fi
105
72cp "$WORK_DIR/appcast.xml" "$ROOT/appcast.xml"106cp "$WORK_DIR/appcast.xml" "$ROOT/appcast.xml"
73 107
74echo "Appcast generated (appcast.xml). Upload alongside $ZIP at $FEED_URL"108echo "Appcast generated (appcast.xml). Upload alongside $ZIP at $FEED_URL"