Parse series-76320 style search hits from TheTVDB v4, document Gear Lever Forgejo setup, and adjust AppImage build metadata for update detection. Co-authored-by: Cursor <[email protected]>
85 lines
2.5 KiB
Bash
Executable File
85 lines
2.5 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# Push tag to Gitea and publish HSRename.AppImage as a release asset.
|
|
# Usage:
|
|
# GITEA_TOKEN=your_token ./release_gitea.sh
|
|
# Optional: ./release_gitea.sh --build (rebuild AppImage first)
|
|
#
|
|
# Requires: curl, git, and network access to your Gitea instance.
|
|
|
|
set -euo pipefail
|
|
cd "$(dirname "$0")"
|
|
|
|
GITEA_HOST="${GITEA_HOST:-https://git.hisora.dev}"
|
|
GITEA_OWNER="${GITEA_OWNER:-Dawnsorrow}"
|
|
if remote_url="$(git remote get-url origin 2>/dev/null)"; then
|
|
GITEA_REPO="$(basename "${remote_url%.git}")"
|
|
elif [[ -z "${GITEA_REPO:-}" ]]; then
|
|
GITEA_REPO="HS-Rename"
|
|
fi
|
|
GITEA_REPO="${GITEA_REPO:-HS-Rename}"
|
|
APP_IMAGE="HSRename.AppImage"
|
|
|
|
VERSION="$(tr -d '[:space:]' < VERSION)"
|
|
TAG="v${VERSION}"
|
|
|
|
if [[ "${1:-}" == "--build" ]]; then
|
|
export PATH="/tmp:${PATH}"
|
|
if ! command -v appimagetool &>/dev/null && [[ -x /tmp/appimagetool ]]; then
|
|
export PATH="/tmp:${PATH}"
|
|
fi
|
|
./build_appimage.sh
|
|
fi
|
|
|
|
if [[ ! -f "$APP_IMAGE" ]]; then
|
|
echo "Missing $APP_IMAGE. Run ./build_appimage.sh or ./release_gitea.sh --build"
|
|
exit 1
|
|
fi
|
|
|
|
if ! git rev-parse "$TAG" >/dev/null 2>&1; then
|
|
echo "Tag $TAG not found. Create it with: git tag $TAG"
|
|
exit 1
|
|
fi
|
|
|
|
echo "=== Pushing main and tag $TAG ==="
|
|
git push origin main
|
|
git push origin "$TAG"
|
|
|
|
if [[ -z "${GITEA_TOKEN:-}" ]]; then
|
|
echo ""
|
|
echo "Code and tag pushed. To upload the AppImage, set GITEA_TOKEN and re-run:"
|
|
echo " GITEA_TOKEN=... ./release_gitea.sh"
|
|
echo ""
|
|
echo "Or create the release manually on Gitea and attach $APP_IMAGE."
|
|
exit 0
|
|
fi
|
|
|
|
API="${GITEA_HOST}/api/v1/repos/${GITEA_OWNER}/${GITEA_REPO}/releases"
|
|
NOTES="$(cat <<EOF
|
|
## HSRename ${TAG}
|
|
|
|
See repository history for changes in this release.
|
|
|
|
Gear Lever update URL:
|
|
\`${GITEA_HOST}/${GITEA_OWNER}/${GITEA_REPO}/releases/download/${TAG}/${APP_IMAGE}\`
|
|
EOF
|
|
)"
|
|
|
|
echo "=== Creating Gitea release $TAG on ${GITEA_OWNER}/${GITEA_REPO} ==="
|
|
RELEASE_JSON="$(curl -fsS -X POST "$API" \
|
|
-H "Authorization: token ${GITEA_TOKEN}" \
|
|
-F "tag_name=${TAG}" \
|
|
-F "name=${TAG}" \
|
|
-F "body=${NOTES}")"
|
|
RELEASE_ID="$(python3 -c "import json,sys; print(json.loads(sys.argv[1])['id'])" "$RELEASE_JSON")"
|
|
|
|
echo "=== Uploading ${APP_IMAGE} (${RELEASE_ID}) ==="
|
|
curl -fsS --max-time 300 -X POST \
|
|
"${API}/${RELEASE_ID}/assets?name=${APP_IMAGE}" \
|
|
-H "Authorization: token ${GITEA_TOKEN}" \
|
|
-F "attachment=@${APP_IMAGE}" >/dev/null
|
|
|
|
echo ""
|
|
echo "Release published:"
|
|
echo " ${GITEA_HOST}/${GITEA_OWNER}/${GITEA_REPO}/releases/tag/${TAG}"
|
|
echo " ${GITEA_HOST}/${GITEA_OWNER}/${GITEA_REPO}/releases/download/${TAG}/${APP_IMAGE}"
|