2026-10-18 15:19:57 -07:00
|
|
|
#!/bin/sh
|
|
|
|
|
set -eu
|
|
|
|
|
mac=$(cd "$(dirname "$0")" && pwd)
|
|
|
|
|
root=$(dirname "$mac")
|
2026-10-18 15:32:07 -07:00
|
|
|
repo=ai/byre
|
2026-10-18 15:19:57 -07:00
|
|
|
api=https://g.fc.run/api/v1/repos/$repo
|
|
|
|
|
|
|
|
|
|
if [ -n "$(git -C "$root" status --porcelain)" ]; then
|
|
|
|
|
echo "release: the tree has uncommitted changes" >&2
|
|
|
|
|
exit 1
|
|
|
|
|
fi
|
|
|
|
|
tag=$(git -C "$root" describe --tags --exact-match HEAD)
|
|
|
|
|
version=${tag#v}
|
|
|
|
|
git -C "$root" fetch origin "refs/tags/$tag"
|
|
|
|
|
if [ "$(git -C "$root" rev-parse "FETCH_HEAD^{commit}")" != "$(git -C "$root" rev-parse HEAD)" ]; then
|
|
|
|
|
echo "release: $tag on origin is not HEAD" >&2
|
|
|
|
|
exit 1
|
|
|
|
|
fi
|
|
|
|
|
token=$(security find-generic-password -s byre-release -w)
|
2026-10-19 16:59:59 -07:00
|
|
|
CLOUDFLARE_API_TOKEN=$(security find-generic-password -s byre-cloudflare -w)
|
|
|
|
|
CLOUDFLARE_ACCOUNT_ID=96e4d3199efaa07ddc5c33e0e2d59c01
|
|
|
|
|
export CLOUDFLARE_API_TOKEN CLOUDFLARE_ACCOUNT_ID
|
2026-10-18 16:58:27 -07:00
|
|
|
notes=$(cat "$1")
|
2026-10-18 15:19:57 -07:00
|
|
|
|
2026-10-18 16:14:03 -07:00
|
|
|
"$mac/package.sh"
|
2026-10-18 15:19:57 -07:00
|
|
|
out=$mac/.build/release/$version
|
|
|
|
|
dmg=byre-$version.dmg
|
|
|
|
|
|
2026-10-19 16:59:59 -07:00
|
|
|
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
|
|
|
|
|
|
2026-10-18 15:19:57 -07:00
|
|
|
request=$out/release.json
|
|
|
|
|
plutil -create xml1 "$request"
|
|
|
|
|
plutil -insert tag_name -string "$tag" "$request"
|
|
|
|
|
plutil -insert name -string "byre $version" "$request"
|
|
|
|
|
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 -)
|
2026-10-19 16:59:59 -07:00
|
|
|
for file in "$dmg" "$dmg.sha256"; do
|
2026-10-18 15:19:57 -07:00
|
|
|
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"
|
|
|
|
|
echo "https://g.fc.run/$repo/releases/tag/$tag"
|