#!/bin/sh # Adds a release to the Sparkle appcast, newest first: signs the DMG with the EdDSA key in the # keychain (sign_update, from the Sparkle package in .build/artifacts) and writes the item. # Usage: scripts/appcast-add.sh set -eu appcast="${1:?usage: appcast-add.sh }" version="${2:?version}" build="${3:?build}" dmg="${4:?dmg}" notes="${5:?notes-file}" cd "$(dirname "$0")/.." ! grep -q "$version<" "$appcast" || { echo "$appcast already has $version." >&2; exit 1; } # SIGN_UPDATE names another signer, for a dry run without the key. sign_update="${SIGN_UPDATE:-$(find .build/artifacts -path '*/Sparkle/bin/sign_update' | head -1)}" [ -n "$sign_update" ] || { echo "sign_update not in .build/artifacts; swift build fetches Sparkle." >&2; exit 1; } signature="$("$sign_update" "$dmg")" # sparkle:edSignature="..." length="..." date="$(LC_ALL=C date -R)" name="$(basename "$dmg")" item="$(mktemp)" { echo " " echo " orgstar $version" echo " https://krz.sh/apps/orgstar/" echo " $build" echo " $version" echo " 26.0" echo " $date" echo " " echo " " echo " " } > "$item" # After the channel's , so the newest release comes first. awk -v item="$item" 'BEGIN { done = 0 } { print } /<\/link>/ && !done { while ((getline line < item) > 0) print line; done = 1 }' "$appcast" > "$appcast.new" mv "$appcast.new" "$appcast" rm -f "$item" xmllint --noout "$appcast" echo "$appcast: added $version"