#!/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 </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}"