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
66 "Usage: $0 CodexBar-<ver>.zip"}
77 FEED_URL=${2:-"https://raw.githubusercontent.com/steipete/CodexBar/main/appcast.xml"}
88 PRIVATE_KEY_FILE=${SPARKLE_PRIVATE_KEY_FILE:-}
9+SPARKLE_CHANNEL=${SPARKLE_CHANNEL:-}
910 if [[ -z "$PRIVATE_KEY_FILE" ]]; then
1011 echo "Set SPARKLE_PRIVATE_KEY_FILE to your ed25519 private key (Sparkle)." >&2
1112 exit 1
@@ -69,6 +70,39 @@ generate_appcast \ · 57 unmodified lines
6970 "$WORK_DIR"
7071 popd >/dev/null
7172
73+if [[ -n "$SPARKLE_CHANNEL" ]]; then
74+ python3 - "$WORK_DIR/appcast.xml" "$VERSION" "$SPARKLE_CHANNEL" <<'PY'
75+import re
76+import sys
77+
78+path, version, channel = sys.argv[1], sys.argv[2], sys.argv[3]
79+with open(path, "r", encoding="utf-8") as handle:
80+ lines = handle.read().splitlines()
81+
82+target = f"<sparkle:shortVersionString>{version}</sparkle:shortVersionString>"
83+try:
84+ index = next(i for i, line in enumerate(lines) if target in line)
85+except StopIteration as exc:
86+ raise SystemExit(f"Could not find {target} in {path}") from exc
87+
88+for 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
97+else:
98+ raise SystemExit(f"Could not find <item> for version {version} in {path}")
99+
100+with open(path, "w", encoding="utf-8") as handle:
101+ handle.write("\n".join(lines) + "\n")
102+PY
103+ echo "Tagged ${VERSION} with sparkle:channel=\"${SPARKLE_CHANNEL}\""
104+fi
105+
72106 cp "$WORK_DIR/appcast.xml" "$ROOT/appcast.xml"
73107
74108 echo "Appcast generated (appcast.xml). Upload alongside $ZIP at $FEED_URL"