fix: publish-release.sh — use release id + multipart attachment upload
This commit is contained in:
parent
09c191a8be
commit
5e0b70a1f7
@ -21,22 +21,25 @@ 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
|
||||
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/$TAG/assets" \
|
||||
-H "Content-Type: application/octet-stream" \
|
||||
--data-binary @"$f" > /dev/null; then
|
||||
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
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user