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"
|
API="$GITEA_URL/api/v1/repos/$GITEA_REPO"
|
||||||
|
|
||||||
# Create the release if it does not exist yet.
|
# Create the release if it does not exist yet.
|
||||||
existing="$(curl -sf -u "${AUTH[@]}" "$API/releases/tags/$TAG" 2>/dev/null \
|
if ! curl -sf -u "${AUTH[@]}" "$API/releases/tags/$TAG" > /dev/null 2>&1; then
|
||||||
| 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" \
|
curl -sf -u "${AUTH[@]}" -X POST "$API/releases" \
|
||||||
-H "Content-Type: application/json" \
|
-H "Content-Type: application/json" \
|
||||||
-d "{\"tag_name\":\"$TAG\",\"name\":\"$TAG\",\"body\":\"MovieMapper $TAG release. Linux: AppImage + deb. See README for install instructions.\"}" \
|
-d "{\"tag_name\":\"$TAG\",\"name\":\"$TAG\",\"body\":\"MovieMapper $TAG release. Linux: AppImage + deb. See README for install instructions.\"}" \
|
||||||
> /dev/null
|
> /dev/null
|
||||||
echo "created release $TAG"
|
echo "created release $TAG"
|
||||||
|
else
|
||||||
|
echo "release $TAG exists"
|
||||||
fi
|
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
|
uploaded=0
|
||||||
for f in dist/*.AppImage dist/*.deb dist/*.dmg dist/*.exe dist/*.zip; do
|
for f in dist/*.AppImage dist/*.deb dist/*.dmg dist/*.exe dist/*.zip; do
|
||||||
[ -e "$f" ] || continue
|
[ -e "$f" ] || continue
|
||||||
if curl -sf -u "${AUTH[@]}" -X POST "$API/releases/$TAG/assets" \
|
if curl -sf -u "${AUTH[@]}" -X POST "$API/releases/$REL_ID/assets" \
|
||||||
-H "Content-Type: application/octet-stream" \
|
-F "attachment=@$f;type=application/octet-stream" > /dev/null; then
|
||||||
--data-binary @"$f" > /dev/null; then
|
|
||||||
echo "uploaded $(basename "$f")"
|
echo "uploaded $(basename "$f")"
|
||||||
uploaded=$((uploaded + 1))
|
uploaded=$((uploaded + 1))
|
||||||
else
|
else
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user