this repo has no description
at main 84 lines 3.1 kB view raw
1#!/usr/bin/env bash 2set -euo pipefail 3 4ROOT=$(cd "$(dirname "$0")/.." && pwd) 5cd "$ROOT" 6 7source "$ROOT/version.env" 8source "$HOME/Projects/agent-scripts/release/sparkle_lib.sh" 9 10APPCAST="$ROOT/appcast.xml" 11APP_NAME="CodexBar" 12ARTIFACT_PREFIX="CodexBar-" 13BUNDLE_ID="com.steipete.codexbar" 14TAG="v${MARKETING_VERSION}" 15 16err() { echo "ERROR: $*" >&2; exit 1; } 17 18require_clean_worktree 19ensure_changelog_finalized "$MARKETING_VERSION" 20ensure_appcast_monotonic "$APPCAST" "$MARKETING_VERSION" "$BUILD_NUMBER" 21 22swiftformat Sources Tests >/dev/null 23swiftlint --strict 24swift test 25 26"$ROOT/Scripts/sign-and-notarize.sh" 27 28KEY_FILE=$(clean_key "$SPARKLE_PRIVATE_KEY_FILE") 29trap 'rm -f "$KEY_FILE"' EXIT 30 31probe_sparkle_key "$KEY_FILE" 32 33clear_sparkle_caches "$BUNDLE_ID" 34 35echo "Generating Sparkle signature for appcast entry" 36SIGNATURE=$(sign_update --ed-key-file "$KEY_FILE" -p "${APP_NAME}-${MARKETING_VERSION}.zip") 37SIZE=$(stat -f%z "${APP_NAME}-${MARKETING_VERSION}.zip") 38PUBDATE=$(LC_ALL=C date '+%a, %d %b %Y %H:%M:%S %z') 39 40python3 - "$APPCAST" "$MARKETING_VERSION" "$BUILD_NUMBER" "$SIGNATURE" "$SIZE" "$PUBDATE" <<'PY' 41import sys, xml.etree.ElementTree as ET 42appcast, ver, build, sig, size, pub = sys.argv[1:] 43tree = ET.parse(appcast) 44root = tree.getroot() 45ns = {"sparkle": "http://www.andymatuschak.org/xml-namespaces/sparkle"} 46channel = root.find("./channel") 47item = ET.Element("item") 48ET.SubElement(item, "title").text = ver 49ET.SubElement(item, "pubDate").text = pub 50ET.SubElement(item, "link").text = "https://raw.githubusercontent.com/steipete/CodexBar/main/appcast.xml" 51ET.SubElement(item, "{http://www.andymatuschak.org/xml-namespaces/sparkle}version").text = build 52ET.SubElement(item, "{http://www.andymatuschak.org/xml-namespaces/sparkle}shortVersionString").text = ver 53ET.SubElement(item, "{http://www.andymatuschak.org/xml-namespaces/sparkle}minimumSystemVersion").text = "15.0" 54enc = ET.SubElement(item, "enclosure") 55enc.set("url", f"https://github.com/steipete/CodexBar/releases/download/v{ver}/CodexBar-{ver}.zip") 56enc.set("length", size) 57enc.set("type", "application/octet-stream") 58enc.set("{http://www.andymatuschak.org/xml-namespaces/sparkle}edSignature", sig) 59channel.insert(1, item) # after title 60tree.write(appcast, encoding="utf-8", xml_declaration=True) 61PY 62 63verify_appcast_entry "$APPCAST" "$MARKETING_VERSION" "$KEY_FILE" 64 65NOTES_FILE=$(mktemp /tmp/codexbar-notes-XXXX.md) 66extract_notes_from_changelog "$MARKETING_VERSION" "$NOTES_FILE" 67trap 'rm -f "$KEY_FILE" "$NOTES_FILE"' EXIT 68 69if [[ "${RUN_SPARKLE_UPDATE_TEST:-0}" == "1" ]]; then 70 PREV_TAG=$(git tag --sort=-v:refname | sed -n '2p') 71 [[ -z "$PREV_TAG" ]] && err "RUN_SPARKLE_UPDATE_TEST=1 set but no previous tag found" 72 "$ROOT/Scripts/test_live_update.sh" "$PREV_TAG" "v${MARKETING_VERSION}" 73fi 74 75gh release create "$TAG" ${APP_NAME}-${MARKETING_VERSION}.zip ${APP_NAME}-${MARKETING_VERSION}.dSYM.zip \ 76 --title "${APP_NAME} ${MARKETING_VERSION}" \ 77 --notes-file "$NOTES_FILE" 78 79check_assets "$TAG" "$ARTIFACT_PREFIX" 80 81git tag -f "$TAG" 82git push origin main --tags 83 84echo "Release ${MARKETING_VERSION} complete."