MovieMapper/scripts/publish-release.sh
Jarian Cottingham 5e0b70a1f7
Some checks are pending
CI / lint (push) Waiting to run
CI / test (push) Waiting to run
CI / docker-build (push) Waiting to run
CI / security (push) Waiting to run
CI / build-result (push) Blocked by required conditions
fix: publish-release.sh — use release id + multipart attachment upload
2026-08-20 20:48:32 +00:00

57 lines
1.8 KiB
Bash
Executable File

#!/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 <tag> (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.
if ! curl -sf -u "${AUTH[@]}" "$API/releases/tags/$TAG" > /dev/null 2>&1; 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"
else
echo "release $TAG exists"
fi
# Resolve numeric release id (asset upload requires it on this Gitea build).
REL_ID="$(curl -sf -u "${AUTH[@]}" "$API/releases/tags/$TAG" \
| python3 -c 'import json,sys; print(json.load(sys.stdin)["id"])')"
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/$REL_ID/assets" \
-F "attachment=@$f;type=application/octet-stream" > /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"