publish.sh: one release for the whole collection

GAME now accepts a space-separated list and defaults to 'all', building and
attaching every game's zip to a single release instead of one game per tag -
which matches the repo being a collection. Release body is the game's own
README for a single game, or the collection README for several.

Asset upload replaces same-named assets, so re-running is idempotent.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
2026-07-21 17:16:54 -04:00
co-authored by Claude Opus 4.8
parent 6f24502956
commit 15d0169f56
+37 -23
View File
@@ -12,24 +12,37 @@ HERE="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"; cd "$HERE"
HOST="${GITEA_HOST:-https://git.lazypugs.com}"
OWNER="${GITEA_OWNER:-ckoch}"
REPO="${GITEA_REPO:-UltraWidePatches}"
GAME="${GAME:-GundamBreaker4}"
# GAME may be a space-separated list; empty/"all" = every game in games/
GAME="${GAME:-all}"
if [ "$GAME" = "all" ]; then
GAME=$(for d in games/*/; do [ -f "$d/game.conf" ] && basename "$d"; done | tr '\n' ' ')
fi
TAG="${TAG:-v1.0.0}"
NOTES="${NOTES:-games/$GAME/README.md}"
[ -f "$NOTES" ] || NOTES="RELEASE_NOTES.md"
# Single game -> its own README; multiple -> the collection README.
if [ "$(echo "$GAME" | wc -w)" -eq 1 ] && [ -f "games/$GAME/README.md" ]; then
NOTES="${NOTES:-games/$GAME/README.md}"
else
NOTES="${NOTES:-README.md}"
fi
[ -f "$NOTES" ] || NOTES="README.md"
API="$HOST/api/v1"
[ -n "${GITEA_TOKEN:-}" ] || { echo "[!] GITEA_TOKEN is not set. Create one at $HOST/user/settings/applications (scope: write:repository)"; exit 1; }
AUTH=(-H "Authorization: token $GITEA_TOKEN")
ZIPNAME="${GAME}_UltraWide_Fix.zip"
echo "[+] Games in this release: $GAME"
# 1. build the artifact -- do NOT swallow output; a failure here used to exit
# 1. build every artifact -- do NOT swallow output; a failure here used to exit
# the whole script silently because stdout went to /dev/null under `set -e`.
if ! bash tools/build_release.sh "$GAME"; then
echo "[!] build_release.sh failed for game '$GAME' (see above)"; exit 1
fi
ZIP="dist/$ZIPNAME"
[ -f "$ZIP" ] || { echo "[!] build produced no $ZIP"; exit 1; }
echo "[+] Built $ZIP"
ZIPS=""
for g in $GAME; do
if ! bash tools/build_release.sh "$g"; then
echo "[!] build_release.sh failed for game '$g' (see above)"; exit 1
fi
z="dist/${g}_UltraWide_Fix.zip"
[ -f "$z" ] || { echo "[!] build produced no $z"; exit 1; }
ZIPS="$ZIPS $z"
done
echo "[+] Built:$ZIPS"
# 2. push code + tag
git push origin main
@@ -51,23 +64,24 @@ if [ -z "$REL_ID" ]; then
| python3 -c "import sys,json;print(json.load(sys.stdin)['id'])")
echo "[+] Created release $TAG (id=$REL_ID)"
else
echo "[i] Release $TAG exists (id=$REL_ID); replacing asset"
echo "[i] Release $TAG exists (id=$REL_ID); replacing assets"
fi
# 4. upload each zip, replacing any same-named asset already attached
for z in $ZIPS; do
n=$(basename "$z")
OLD=$(curl -sf "${AUTH[@]}" "$API/repos/$OWNER/$REPO/releases/$REL_ID" \
| ZIPNAME="$ZIPNAME" python3 -c "
| ZIPNAME="$n" python3 -c "
import sys, json, os
d = json.load(sys.stdin)
want = os.environ['ZIPNAME']
print(next((str(a['id']) for a in d.get('assets', []) if a['name'] == want), ''))" 2>/dev/null || true)
if [ -n "$OLD" ]; then
curl -sf -X DELETE "${AUTH[@]}" "$API/repos/$OWNER/$REPO/releases/$REL_ID/assets/$OLD" >/dev/null \
&& echo "[i] removed previous asset"
fi
fi
# 4. upload the zip
curl -sf "${AUTH[@]}" -F "attachment=@$ZIP" \
"$API/repos/$OWNER/$REPO/releases/$REL_ID/assets?name=$ZIPNAME" >/dev/null
echo "[+] Uploaded $ZIPNAME"
[ -n "$OLD" ] && curl -sf -X DELETE "${AUTH[@]}" \
"$API/repos/$OWNER/$REPO/releases/$REL_ID/assets/$OLD" >/dev/null && echo "[i] replaced $n"
curl -sf "${AUTH[@]}" -F "attachment=@$z" \
"$API/repos/$OWNER/$REPO/releases/$REL_ID/assets?name=$n" >/dev/null
echo "[+] Uploaded $n"
done
echo
echo "[+] Done: $HOST/$OWNER/$REPO/releases/tag/$TAG"