From c352d88afd19fd9fecb71f95fdb62aa1213c8bd5 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Mon, 18 Dec 2023 21:15:49 -0800 Subject: [PATCH] ci: generate appcast, upload it --- .github/workflows/release-tip.yml | 12 ++++++ dist/macos/update_appcast_tip.py | 66 +++++++++++++++++++++++++++++++ macos/Ghostty-Info.plist | 2 + 3 files changed, 80 insertions(+) create mode 100644 dist/macos/update_appcast_tip.py diff --git a/.github/workflows/release-tip.yml b/.github/workflows/release-tip.yml index 4537f959d..291f6659e 100644 --- a/.github/workflows/release-tip.yml +++ b/.github/workflows/release-tip.yml @@ -179,7 +179,19 @@ jobs: files: ghostty-macos-universal.zip token: ${{ secrets.GH_RELEASE_TOKEN }} + # Create our appcast for Sparkle + - name: Generate Appcast + env: + SPARKLE_KEY: ${{ secrets.PROD_MACOS_SPARKLE_KEY }} + run: | + echo $SPARKLE_KEY > signing.key + sign_update -f signing.key src/App.zig > sign_update.txt + curl -L https://tip.files.ghostty.dev/appcast.xml > appcast.xml + python3 ./dist/macos/update_appcast_tip.py + test -f appcast_new.xml + # Update Blob Storage - name: Upload to Blob Storage run: | s3cmd put ghostty-macos-universal.zip s3://ghostty-tip/${GHOSTTY_BUILD}/ghostty-macos-universal.zip + s3cmd put appcast_new.xml s3://ghostty-tip/appcast.xml diff --git a/dist/macos/update_appcast_tip.py b/dist/macos/update_appcast_tip.py new file mode 100644 index 000000000..ec3878bc1 --- /dev/null +++ b/dist/macos/update_appcast_tip.py @@ -0,0 +1,66 @@ +""" +This script is used to update the appcast.xml file for Ghostty releases. +The script is currently hardcoded to only work for tip releases and therefore +doesn't have rich release notes, hardcodes the URL to the tip bucket, etc. + +This expects the following files in the current directory: + - sign_update.txt - contains the output from "sign_update" in the Sparkle + framework for the current build. + - appcast.xml - the existing appcast file. + +And the following environment variables to be set: + - GHOSTTY_BUILD - the build number + - GHOSTTY_COMMIT - the commit hash + +The script will output a new appcast file called appcast_new.xml. +""" + +import os +import xml.etree.ElementTree as ET +from datetime import datetime, timezone + +now = datetime.now(timezone.utc) +build = os.environ["GHOSTTY_BUILD"] +commit = os.environ["GHOSTTY_COMMIT"] + +# Read our sign_update output +with open("sign_update.txt", "r") as f: + # format is a=b b=c etc. create a map of this. values may contain equal + # signs, so we can't just split on equal signs. + attrs = {} + for pair in f.read().split(" "): + key, value = pair.split("=", 1) + value = value.strip() + if value[0] == '"': + value = value[1:-1] + attrs[key] = value + +# Open our existing appcast and find the channel element. This is where +# we'll add our new item. +et = ET.parse('appcast.xml') +channel = et.find("channel") + +# Create the item using some absoultely terrible XML manipulation. +item = ET.SubElement(channel, "item") +elem = ET.SubElement(item, "title") +elem.text = f"Build {build}" +elem = ET.SubElement(item, "pubDate") +elem.text = now.strftime("%a, %d %b %Y %H:%M:%S %z") +elem = ET.SubElement(item, "sparkle:version") +elem.text = build +elem = ET.SubElement(item, "sparkle:shortVersionString") +elem.text = commit +elem = ET.SubElement(item, "sparkle:minimumSystemVersion") +elem.text = "12.0.0" +elem = ET.SubElement(item, "description") +elem.text = f""" +

Automated build from commit

{commit}
.

+""" +elem = ET.SubElement(item, "enclosure") +elem.set("url", f"https://tip.files.ghostty.dev/{build}/ghostty-macos-universal.zip") +elem.set("type", "application/octet-stream") +for key, value in attrs.items(): + elem.set(key, value) + +# Output the new appcast. +et.write("appcast_new.xml") diff --git a/macos/Ghostty-Info.plist b/macos/Ghostty-Info.plist index f0311e217..a2066680c 100644 --- a/macos/Ghostty-Info.plist +++ b/macos/Ghostty-Info.plist @@ -91,6 +91,8 @@ A program in Ghostty wants to use speech recognition. NSSystemAdministrationUsageDescription A program in Ghostty requires elevated privileges. + SUPublicEDKey + wsNcGf5hirwtdXMVnYoxRIX/SqZQLMOsYlD3q3imeok= CFBundleVersion CFBundleShortVersionString