Files
HS-Rename/release_gitea.sh
T
Bulk RenamerandCursor c54ee7876c Fix AppImage verify step to inspect the PyInstaller binary.
The squashfs wrapper does not contain module path strings reliably.

Co-authored-by: Cursor <[email protected]>
2026-07-03 17:23:45 -05:00

105 lines
3.3 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
#
# Always rebuilds the AppImage before upload so releases never ship a stale binary.
#
# Requires: curl, git, appimagetool, 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}"
verify_appimage() {
if [[ ! -f "$APP_IMAGE" ]]; then
echo "Missing $APP_IMAGE after build." >&2
exit 1
fi
if [[ ! -f "dist/HSRename/HSRename" ]]; then
echo "Missing dist/HSRename/HSRename after build." >&2
exit 1
fi
if ! strings "dist/HSRename/HSRename" | grep -q "engine.tvdb_client"; then
echo "ERROR: Built executable is missing TheTVDB modules; refusing to publish." >&2
exit 1
fi
if ! strings "dist/HSRename/HSRename" | grep -q "engine.episode_match"; then
echo "ERROR: Built executable is missing episode matching; refusing to publish." >&2
exit 1
fi
}
export PATH="/tmp:${PATH}"
if ! command -v appimagetool &>/dev/null && [[ -x /tmp/appimagetool ]]; then
export PATH="/tmp:${PATH}"
fi
if ! command -v appimagetool &>/dev/null; then
curl -fsSL -o /tmp/appimagetool "https://github.com/AppImage/appimagetool/releases/download/continuous/appimagetool-x86_64.AppImage"
chmod +x /tmp/appimagetool
export PATH="/tmp:${PATH}"
fi
echo "=== Building fresh AppImage for ${TAG} ==="
./build_appimage.sh
verify_appimage
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 "Built and verified $APP_IMAGE. Set GITEA_TOKEN and re-run to upload:"
echo " GITEA_TOKEN=... ./release_gitea.sh"
exit 0
fi
API="${GITEA_HOST}/api/v1/repos/${GITEA_OWNER}/${GITEA_REPO}/releases"
NOTES="$(cat <<EOF
## HSRename ${TAG}
- Fix botched v1.0.4 AppImage (restores TheTVDB episode match + search fix)
- Always verify/update via Gear Lever Forgejo: \`https://git.hisora.dev/Dawnsorrow/HS-Rename\`
Download:
\`${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}"