Showing the changes to Scripts (1 of 7 files). Show all
Unified · Split
| @@ -6,6 +6,7 @@ ZIP=${1:? · 5 unmodified lines | ||
| 6 | 6 | "Usage: $0 CodexBar-<ver>.zip"} |
| 7 | 7 | FEED_URL=${2:-"https://raw.githubusercontent.com/steipete/CodexBar/main/appcast.xml"} |
| 8 | 8 | PRIVATE_KEY_FILE=${SPARKLE_PRIVATE_KEY_FILE:-} |
| 9 | +SPARKLE_CHANNEL=${SPARKLE_CHANNEL:-} | |
| 9 | 10 | if [[ -z "$PRIVATE_KEY_FILE" ]]; then |
| 10 | 11 | echo "Set SPARKLE_PRIVATE_KEY_FILE to your ed25519 private key (Sparkle)." >&2 |
| 11 | 12 | exit 1 |
| @@ -69,6 +70,39 @@ generate_appcast \ · 57 unmodified lines | ||
| 69 | 70 | "$WORK_DIR" |
| 70 | 71 | popd >/dev/null |
| 71 | 72 | |
| 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 | + | |
| 72 | 106 | cp "$WORK_DIR/appcast.xml" "$ROOT/appcast.xml" |
| 73 | 107 | |
| 74 | 108 | echo "Appcast generated (appcast.xml). Upload alongside $ZIP at $FEED_URL" |