39 lines
1.5 KiB
Bash
Executable File
39 lines
1.5 KiB
Bash
Executable File
#!/bin/sh
|
|
set -eu
|
|
mac=$(cd "$(dirname "$0")" && pwd)
|
|
root=$(dirname "$mac")
|
|
repo=ai/byre
|
|
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)
|
|
notes=$(cat "$1")
|
|
|
|
"$mac/package.sh"
|
|
out=$mac/.build/release/$version
|
|
dmg=byre-$version.dmg
|
|
|
|
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 -)
|
|
for file in "$dmg" "$dmg.sha256" appcast.xml; 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"
|
|
echo "https://g.fc.run/$repo/releases/tag/$tag"
|