Files
byre/mac/package.sh
T

59 lines
2.0 KiB
Bash
Raw Normal View History

2026-10-18 16:14:03 -07:00
#!/bin/sh
set -eu
mac=$(cd "$(dirname "$0")" && pwd)
repo=ai/byre
sparkle_version=2.10.0
sparkle=$HOME/Library/Caches/byre/sparkle-$sparkle_version
identity="Developer ID Application"
if [ ! -x "$sparkle/bin/sign_update" ]; then
mkdir -p "$sparkle"
curl -fsSL "https://github.com/sparkle-project/Sparkle/releases/download/$sparkle_version/Sparkle-$sparkle_version.tar.xz" | tar -xJ -C "$sparkle"
fi
"$mac/bundle.sh"
app=$mac/.build/Byre.app
version=$(plutil -extract CFBundleShortVersionString raw "$app/Contents/Info.plist")
tag=v$version
out=$mac/.build/release/$version
rm -rf "$out"
mkdir -p "$out"
ditto -c -k --keepParent "$app" "$out/byre.zip"
xcrun notarytool submit "$out/byre.zip" --keychain-profile byre-notary --wait
xcrun stapler staple "$app"
rm "$out/byre.zip"
dmg=byre-$version.dmg
stage=$out/stage
mkdir "$stage"
ditto "$app" "$stage/Byre.app"
ln -s /Applications "$stage/Applications"
hdiutil create -volname byre -srcfolder "$stage" -format UDZO "$out/$dmg"
rm -rf "$stage"
codesign --force --timestamp --sign "$identity" "$out/$dmg"
xcrun notarytool submit "$out/$dmg" --keychain-profile byre-notary --wait
xcrun stapler staple "$out/$dmg"
(cd "$out" && shasum -a 256 "$dmg" > "$dmg.sha256")
build=$(plutil -extract CFBundleVersion raw "$app/Contents/Info.plist")
minimum=$(plutil -extract LSMinimumSystemVersion raw "$app/Contents/Info.plist")
signature=$("$sparkle/bin/sign_update" --account byre "$out/$dmg")
cat > "$out/appcast.xml" <<EOF
<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:sparkle="http://www.andymatuschak.org/xml-namespaces/sparkle">
<channel>
<title>byre</title>
<item>
<title>byre $version</title>
<pubDate>$(LC_ALL=C date -u "+%a, %d %b %Y %H:%M:%S +0000")</pubDate>
<sparkle:version>$build</sparkle:version>
<sparkle:shortVersionString>$version</sparkle:shortVersionString>
<sparkle:minimumSystemVersion>$minimum</sparkle:minimumSystemVersion>
<enclosure url="https://g.fc.run/$repo/releases/download/$tag/$dmg" type="application/octet-stream" $signature/>
</item>
</channel>
</rss>
EOF
echo "$out/$dmg"