#!/usr/bin/env bash # # Publish built artifacts (dist/) as a Gitea release with attached assets. # # Usage: # GITEA_PASS=... ./scripts/publish-release.sh v1.0.0 # # Environment: # GITEA_URL (default: https://git.example.com) # GITEA_USER (default: jarianc) # GITEA_PASS (required) # GITEA_REPO (default: jarianc/MovieMapper) set -euo pipefail TAG="${1:?usage: publish-release.sh (e.g. v1.0.0)}" GITEA_URL="${GITEA_URL:-https://git.example.com}" GITEA_USER="${GITEA_USER:-jarianc}" GITEA_PASS="${GITEA_PASS:?GITEA_PASS is required}" GITEA_REPO="${GITEA_REPO:-jarianc/MovieMapper}" AUTH=("${GITEA_USER}:${GITEA_PASS}") API="$GITEA_URL/api/v1/repos/$GITEA_REPO" # Create the release if it does not exist yet. existing="$(curl -sf -u "${AUTH[@]}" "$API/releases/tags/$TAG" 2>/dev/null \ | python3 -c 'import json,sys; print(json.load(sys.stdin).get("id",""))' || true)" if [ -z "${existing}" ]; then curl -sf -u "${AUTH[@]}" -X POST "$API/releases" \ -H "Content-Type: application/json" \ -d "{\"tag_name\":\"$TAG\",\"name\":\"$TAG\",\"body\":\"MovieMapper $TAG release. Linux: AppImage + deb. See README for install instructions.\"}" \ > /dev/null echo "created release $TAG" fi uploaded=0 for f in dist/*.AppImage dist/*.deb dist/*.dmg dist/*.exe dist/*.zip; do [ -e "$f" ] || continue if curl -sf -u "${AUTH[@]}" -X POST "$API/releases/$TAG/assets" \ -H "Content-Type: application/octet-stream" \ --data-binary @"$f" > /dev/null; then echo "uploaded $(basename "$f")" uploaded=$((uploaded + 1)) else echo "FAILED to upload $f" >&2 exit 1 fi done if [ "$uploaded" -eq 0 ]; then echo "no artifacts found in dist/ — run npm run dist first" >&2 exit 1 fi echo "done: $uploaded assets on release $TAG"