Migrate to self-hosted Gitea
- origin now points at git.lazypugs.com/ckoch/UltraWidePatches - rewrite tools/publish.sh for Gitea's API (token via GITEA_TOKEN env, never stored on disk); creates/updates the release and uploads the game zip - update the remaining self-referential link to the Gitea URL Upstream links (SUWSF, Ultimate ASI Loader, Lyall's patterns) intentionally still point at GitHub - those are third-party projects. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
+51
-37
@@ -1,51 +1,65 @@
|
||||
#!/usr/bin/env bash
|
||||
# One-shot publish to GitHub. Run AFTER authenticating gh (see below).
|
||||
# Publish a release to Gitea (git.lazypugs.com).
|
||||
#
|
||||
# Auth options (pick one):
|
||||
# export GH_TOKEN=ghp_xxx # a token with 'repo' + 'workflow' scope
|
||||
# gh auth login # interactive
|
||||
# Auth: needs a Gitea token with 'write:repository'. Never hardcode it.
|
||||
# export GITEA_TOKEN=... # from your shell / password manager
|
||||
# ./tools/publish.sh # or: GAME=GundamBreaker4 TAG=v1.0.1 ./tools/publish.sh
|
||||
#
|
||||
# Usage:
|
||||
# ./tools/publish.sh [REPO_NAME] [--private]
|
||||
# (defaults: repo name "UltraWidePatches", public)
|
||||
# GAME=GundamBreaker4 selects which game's zip to attach (default: GundamBreaker4)
|
||||
# Steps: build the game's zip -> push branch+tag -> create release -> upload asset.
|
||||
set -euo pipefail
|
||||
HERE="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"; cd "$HERE"
|
||||
|
||||
REPO="${1:-UltraWidePatches}"
|
||||
VIS="--public"; [ "${2:-}" = "--private" ] && VIS="--private"
|
||||
TAG="v1.0.0"
|
||||
|
||||
command -v gh >/dev/null || { echo "[!] gh not installed"; exit 1; }
|
||||
gh auth status >/dev/null 2>&1 || { echo "[!] Not authenticated. Set GH_TOKEN or run 'gh auth login'."; exit 1; }
|
||||
OWNER="$(gh api user -q .login)"
|
||||
echo "[+] Publishing as: $OWNER repo: $REPO $VIS"
|
||||
|
||||
# 1. build the release artifact fresh
|
||||
HOST="${GITEA_HOST:-https://git.lazypugs.com}"
|
||||
OWNER="${GITEA_OWNER:-ckoch}"
|
||||
REPO="${GITEA_REPO:-UltraWidePatches}"
|
||||
GAME="${GAME:-GundamBreaker4}"
|
||||
TAG="${TAG:-v1.0.0}"
|
||||
NOTES="${NOTES:-RELEASE_NOTES.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"
|
||||
|
||||
# 1. build the artifact
|
||||
bash tools/build_release.sh "$GAME" >/dev/null
|
||||
echo "[+] Built dist/${GAME}_UltraWide_Fix.zip"
|
||||
ZIP="dist/$ZIPNAME"
|
||||
[ -f "$ZIP" ] || { echo "[!] build produced no $ZIP"; exit 1; }
|
||||
echo "[+] Built $ZIP"
|
||||
|
||||
# 2. create the repo (skip if it already exists) and set as origin
|
||||
if gh repo view "$OWNER/$REPO" >/dev/null 2>&1; then
|
||||
echo "[i] Repo exists; reusing."
|
||||
git remote get-url origin >/dev/null 2>&1 || git remote add origin "https://github.com/$OWNER/$REPO.git"
|
||||
# 2. push code + tag
|
||||
git push origin main
|
||||
git push origin "$TAG" 2>/dev/null || echo "[i] tag $TAG already on remote"
|
||||
|
||||
# 3. create the release (or reuse if it already exists)
|
||||
REL_ID=$(curl -sf "${AUTH[@]}" "$API/repos/$OWNER/$REPO/releases/tags/$TAG" 2>/dev/null \
|
||||
| python3 -c "import sys,json;print(json.load(sys.stdin)['id'])" 2>/dev/null || true)
|
||||
|
||||
if [ -z "$REL_ID" ]; then
|
||||
BODY=$(python3 -c "import json,sys;print(json.dumps(open(sys.argv[1]).read()))" "$NOTES")
|
||||
REL_ID=$(curl -sf "${AUTH[@]}" -H "Content-Type: application/json" \
|
||||
-d "{\"tag_name\":\"$TAG\",\"name\":\"$TAG\",\"body\":$BODY}" \
|
||||
"$API/repos/$OWNER/$REPO/releases" \
|
||||
| python3 -c "import sys,json;print(json.load(sys.stdin)['id'])")
|
||||
echo "[+] Created release $TAG (id=$REL_ID)"
|
||||
else
|
||||
gh repo create "$OWNER/$REPO" $VIS --source=. --remote=origin \
|
||||
--description="Ultrawide (32:9/21:9) fixes for PC games — Hor+ FOV via SUWSF. Proton-first."
|
||||
echo "[i] Release $TAG exists (id=$REL_ID); replacing asset"
|
||||
OLD=$(curl -sf "${AUTH[@]}" "$API/repos/$OWNER/$REPO/releases/$REL_ID" \
|
||||
| ZIPNAME="$ZIPNAME" 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
|
||||
|
||||
# 3. push branch + tag
|
||||
git push -u origin main
|
||||
git push origin "$TAG"
|
||||
|
||||
# 4. create the release with notes + zip asset (idempotent)
|
||||
if gh release view "$TAG" -R "$OWNER/$REPO" >/dev/null 2>&1; then
|
||||
gh release upload "$TAG" "dist/${GAME}_UltraWide_Fix.zip" -R "$OWNER/$REPO" --clobber
|
||||
else
|
||||
gh release create "$TAG" "dist/${GAME}_UltraWide_Fix.zip" \
|
||||
-R "$OWNER/$REPO" -t "$TAG" -F RELEASE_NOTES.md
|
||||
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"
|
||||
|
||||
echo
|
||||
echo "[+] Done: https://github.com/$OWNER/$REPO/releases/tag/$TAG"
|
||||
echo "[+] Done: $HOST/$OWNER/$REPO/releases/tag/$TAG"
|
||||
|
||||
Reference in New Issue
Block a user