more Sparkle tests

This commit is contained in:
Micha
2025-11-26 18:43:01 +01:00
parent dc7a516b6d
commit 1945b1dedb
3 changed files with 52 additions and 10 deletions

View File

@@ -29,12 +29,8 @@ find_generate_appcast() {
generate_appcast() {
local generator
generator="$(find_generate_appcast)"
local download_prefix=""
if [[ -n "${SPARKLE_DOWNLOAD_BASE_TEMPLATE:-}" ]]; then
download_prefix="${SPARKLE_DOWNLOAD_BASE_TEMPLATE//\{\{VERSION\}\}/$VERSION}"
else
download_prefix="${SPARKLE_DOWNLOAD_BASE_URL:-}"
fi
local download_prefix="${SPARKLE_DOWNLOAD_BASE_URL:-}"
local version_prefix="${SPARKLE_DOWNLOAD_VERSION_PREFIX:-}"
if [[ -z "$generator" || -z "${SPARKLE_EDDSA_KEY_FILE:-}" || -z "$download_prefix" ]]; then
echo " Skipping Sparkle appcast generation (generator/key/download prefix not configured)."
@@ -61,6 +57,7 @@ generate_appcast() {
"$staging_dir"; then
echo "⚠️ Sparkle appcast generation failed."
fi
rewrite_appcast_urls "$output" "$version_prefix"
rm -rf "$staging_dir"
}
@@ -77,6 +74,49 @@ sign_update_artifacts() {
fi
}
rewrite_appcast_urls() {
local appcast="$1"
local version_prefix="$2"
local marker="${SPARKLE_DOWNLOAD_VERSION_MARKER:-/releases/download/}"
if [[ -z "$version_prefix" || -z "$marker" ]]; then
return
fi
python3 - "$appcast" "$marker" "$version_prefix" <<'PY'
import sys
import xml.etree.ElementTree as ET
path, marker, prefix = sys.argv[1:]
tree = ET.parse(path)
root = tree.getroot()
ns = {'sparkle': 'http://www.andymatuschak.org/xml-namespaces/sparkle'}
changed = False
for item in root.findall('.//item'):
short = item.find('sparkle:shortVersionString', ns)
enclosure = item.find('enclosure')
if short is None or enclosure is None:
continue
version = (short.text or '').strip()
url = enclosure.get('url')
if not version or not url or marker not in url:
continue
desired = f"{marker}{prefix}{version}/"
if desired in url:
continue
base, rest = url.split(marker, 1)
if rest.startswith(f"{prefix}{version}/"):
continue
new_rest = f"{prefix}{version}/{rest.lstrip('/')}"
enclosure.set('url', f"{base}{marker}{new_rest}")
changed = True
if changed:
ET.indent(tree, space=" ", level=0)
tree.write(path, encoding='utf-8', xml_declaration=True)
PY
}
submit_for_notarization() {
local target="$1"
local label="$2"