more Sparkle tests

This commit is contained in:
Micha
2025-11-26 18:53:14 +01:00
parent 473354a50a
commit eadd8e9d28
4 changed files with 12 additions and 50 deletions

View File

@@ -29,8 +29,12 @@ find_generate_appcast() {
generate_appcast() {
local generator
generator="$(find_generate_appcast)"
local download_prefix="${SPARKLE_DOWNLOAD_BASE_URL:-}"
local version_prefix="${SPARKLE_DOWNLOAD_VERSION_PREFIX:-}"
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
if [[ -z "$generator" || -z "${SPARKLE_EDDSA_KEY_FILE:-}" || -z "$download_prefix" ]]; then
echo " Skipping Sparkle appcast generation (generator/key/download prefix not configured)."
@@ -57,7 +61,6 @@ generate_appcast() {
"$staging_dir"; then
echo "⚠️ Sparkle appcast generation failed."
fi
rewrite_appcast_urls "$output" "$version_prefix"
rm -rf "$staging_dir"
}
@@ -75,46 +78,7 @@ sign_update_artifacts() {
}
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
: # no-op (old helper removed)
}
submit_for_notarization() {