diff --git a/release.sh b/release.sh index 3f263e1..af11119 100755 --- a/release.sh +++ b/release.sh @@ -182,7 +182,7 @@ CREATE_RESPONSE="$(curl -fsSL \ -H "Content-Type: application/json" \ -d "$CREATE_PAYLOAD")" -RELEASE_ID="$(echo "$CREATE_RESPONSE" | jq -r '.id')" +RELEASE_ID="$(jq -r '.id' <<< "$CREATE_RESPONSE")" [[ -n "$RELEASE_ID" && "$RELEASE_ID" != "null" ]] \ || fail "Gitea create-release response missing id: $CREATE_RESPONSE" @@ -192,14 +192,28 @@ log "Created Gitea release id=$RELEASE_ID" log "Uploading asset $ZIP_NAME to release id=$RELEASE_ID" -UPLOAD_RESPONSE="$(curl -fsSL \ +curl -fsSL \ -X POST "${GITEA_API}/repos/${REPO_OWNER}/${REPO_NAME}/releases/${RELEASE_ID}/assets?name=${ZIP_NAME}" \ -H "Authorization: token ${TOKEN}" \ - -F "attachment=@${ZIP_PATH};type=application/zip")" + -F "attachment=@${ZIP_PATH};type=application/zip" \ + -o /dev/null + +# Gitea's asset upload response returns an internal /attachments/ URL, +# but the release detail endpoint returns the pretty /releases/download// +# URL for the same asset. Both resolve to the same bytes; the pretty URL is +# preferred for readability and WP-admin UX. +RELEASE_DETAIL="$(curl -fsSL \ + "${GITEA_API}/repos/${REPO_OWNER}/${REPO_NAME}/releases/${RELEASE_ID}" \ + -H "Authorization: token ${TOKEN}")" + +# Use herestring instead of `echo | jq`: `echo` on macOS may interpret +# backslash-escapes in a multi-line release body, corrupting the JSON. +DOWNLOAD_URL="$(jq -r --arg name "$ZIP_NAME" \ + '.assets[] | select(.name == $name) | .browser_download_url' \ + <<< "$RELEASE_DETAIL" | head -n 1)" -DOWNLOAD_URL="$(echo "$UPLOAD_RESPONSE" | jq -r '.browser_download_url')" [[ -n "$DOWNLOAD_URL" && "$DOWNLOAD_URL" != "null" ]] \ - || fail "Gitea asset upload response missing browser_download_url: $UPLOAD_RESPONSE" + || fail "release $RELEASE_ID has no asset named $ZIP_NAME" log "Asset uploaded: $DOWNLOAD_URL" diff --git a/wp-plugin-info.json b/wp-plugin-info.json index 9e2fdbd..ab5ab78 100644 --- a/wp-plugin-info.json +++ b/wp-plugin-info.json @@ -2,7 +2,7 @@ "name": "CF7 Spam → Telegram", "slug": "cf7-spam-to-telegram", "version": "1.2.0", - "download_url": "https://git.netranking.ru/attachments/a04cdb20-7e80-4703-8c30-1000e5945e8b", + "download_url": "https://git.netranking.ru/bryzgalov/cf7-spam-to-telegram/releases/download/v1.2.0/cf7-spam-to-telegram-1.2.0.zip", "homepage": "https://git.netranking.ru/bryzgalov/cf7-spam-to-telegram", "requires": "6.0", "tested": "6.9",