Host the site and release downloads on byre.run via Cloudflare

This commit is contained in:
Ian Gulliver
2026-10-19 16:59:59 -07:00
parent b9a988e2d5
commit 0be09b3279
9 changed files with 244 additions and 11 deletions
+13 -1
View File
@@ -17,12 +17,24 @@ if [ "$(git -C "$root" rev-parse "FETCH_HEAD^{commit}")" != "$(git -C "$root" re
exit 1
fi
token=$(security find-generic-password -s byre-release -w)
CLOUDFLARE_API_TOKEN=$(security find-generic-password -s byre-cloudflare -w)
CLOUDFLARE_ACCOUNT_ID=96e4d3199efaa07ddc5c33e0e2d59c01
export CLOUDFLARE_API_TOKEN CLOUDFLARE_ACCOUNT_ID
notes=$(cat "$1")
"$mac/package.sh"
out=$mac/.build/release/$version
dmg=byre-$version.dmg
put() {
npx --yes wrangler@4.151.2 r2 object put "byre/$1" --remote --file "$out/$2" --content-type "$3" --cache-control "$4"
}
put "$dmg" "$dmg" application/x-apple-diskimage "public, max-age=31536000, immutable"
put "$dmg.sha256" "$dmg.sha256" text/plain "public, max-age=31536000, immutable"
put byre.dmg "$dmg" application/x-apple-diskimage "public, max-age=300"
put appcast.xml appcast.xml application/xml "public, max-age=300"
curl -fsS -o /dev/null -X POST -H "Authorization: Bearer $CLOUDFLARE_API_TOKEN" -H "Content-Type: application/json" --data '{"files":["https://dl.byre.run/byre.dmg","https://dl.byre.run/appcast.xml"]}' https://api.cloudflare.com/client/v4/zones/b53a5f8cb60313ba6789aba3559cb4b8/purge_cache
request=$out/release.json
plutil -create xml1 "$request"
plutil -insert tag_name -string "$tag" "$request"
@@ -31,7 +43,7 @@ plutil -insert body -string "$notes" "$request"
plutil -insert draft -bool true "$request"
plutil -convert json "$request"
id=$(curl -fsS -X POST -H "Authorization: token $token" -H "Content-Type: application/json" --data-binary "@$request" "$api/releases" | plutil -extract id raw -)
for file in "$dmg" "$dmg.sha256" appcast.xml; do
for file in "$dmg" "$dmg.sha256"; do
curl -fsS -o /dev/null -H "Authorization: token $token" -F "attachment=@$out/$file" "$api/releases/$id/assets?name=$file"
done
curl -fsS -o /dev/null -X PATCH -H "Authorization: token $token" -H "Content-Type: application/json" --data '{"draft":false}' "$api/releases/$id"