2026-10-18 16:14:03 -07:00
#!/bin/sh
set -eu
mac = $( cd " $( dirname " $0 " ) " && pwd )
sparkle_version = 2.10.0
sparkle = $HOME /Library/Caches/byre/sparkle-$sparkle_version
identity = "Developer ID Application"
2026-10-20 08:55:37 -07:00
fields = $( mktemp -d)
team = $( security cms -D -i " $mac /byre.provisionprofile" | plutil -extract TeamIdentifier.0 raw -o - -)
xcrun cktool export-schema --team-id " $team " --container-id iCloud.run.fc.byre.mac --environment production --output-file " $fields /schema"
awk '$1 == "RECORD" && $2 == "TYPE" { type = $3; next } type != "" && $1 ~ /^CD_/ { print type "." $1 } /\);/ { type = "" }' " $fields /schema" |
sort > " $fields /production"
awk '/^@Model/ { model = 1; next } model && /^final class/ { type = $3; next } model && /^ var / { print "CD_" type ".CD_" $2 } /^}/ { model = 0 }' " $mac /Sources/Byre/Persistence.swift" |
sort > " $fields /models"
missing = $( comm -23 " $fields /models" " $fields /production" )
rm -rf " $fields "
if [ -n " $missing " ] ; then
echo "CloudKit's Production schema lacks these SwiftData fields, so iCloud would reject them:" >& 2
echo " $missing " >& 2
echo "Add them to Development and deploy them (docs/operations.md, \"Storage\")." >& 2
exit 1
fi
2026-10-18 16:14:03 -07:00
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" )
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>
2026-10-19 16:59:59 -07:00
<enclosure url="https://dl.byre.run/$dmg" type="application/octet-stream" $signature/>
2026-10-18 16:14:03 -07:00
</item>
</channel>
</rss>
EOF
echo " $out / $dmg "