Fix release asset upload corrupted by echo of API response
The v1.1.0 release job created the release then died with a jq parse error before uploading either package. The runner executes run: steps with a shell whose echo expands backslash escapes. Passing the API response through `echo "$BODY" | jq` turned the \n escapes in the release body field into real newlines, producing invalid JSON. This only surfaced now because the release body became multi-line; every earlier release had a single-line body with no \n to expand. Keep the response in a file and read it with jq directly, so no JSON passes through echo. Also fall back to the existing release for the tag when creation returns non-2xx, so a partially completed release can be re-run. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -82,23 +82,32 @@ jobs:
|
||||
"" \
|
||||
"- \`${{ steps.jprm.outputs.jf11_artifact_name }}\` - Jellyfin 10.11.x" \
|
||||
"- \`${{ steps.jprm.outputs.jf12_artifact_name }}\` - Jellyfin 12.0.x")
|
||||
RESPONSE=$(curl -s -w "\n%{http_code}" -X POST \
|
||||
API_URL="${GITEA_URL}/api/v1/repos/${REPO_OWNER}/${REPO_NAME}"
|
||||
|
||||
# Keep the API response in a file: it contains \n escapes, and `echo` in
|
||||
# this shell expands those into real newlines, which corrupts the JSON.
|
||||
HTTP_CODE=$(curl -s -o release-response.json -w "%{http_code}" -X POST \
|
||||
-H "Authorization: token ${GITEA_TOKEN}" \
|
||||
-H "Content-Type: application/json" \
|
||||
"${GITEA_URL}/api/v1/repos/${REPO_OWNER}/${REPO_NAME}/releases" \
|
||||
"${API_URL}/releases" \
|
||||
-d "$(jq -n --arg tag "$VERSION" --arg name "Release $VERSION" --arg body "$RELEASE_BODY" '{tag_name: $tag, name: $name, body: $body, draft: false, prerelease: false}')")
|
||||
|
||||
HTTP_CODE=$(echo "$RESPONSE" | tail -n1)
|
||||
BODY=$(echo "$RESPONSE" | sed '$d')
|
||||
if [ "$HTTP_CODE" -lt 200 ] || [ "$HTTP_CODE" -ge 300 ]; then
|
||||
echo "Create release returned HTTP ${HTTP_CODE}:"
|
||||
cat release-response.json
|
||||
echo "Falling back to an existing release for ${VERSION}..."
|
||||
curl -sf -o release-response.json \
|
||||
-H "Authorization: token ${GITEA_TOKEN}" \
|
||||
"${API_URL}/releases/tags/${VERSION}"
|
||||
fi
|
||||
|
||||
if [ "$HTTP_CODE" -ge 200 ] && [ "$HTTP_CODE" -lt 300 ]; then
|
||||
RELEASE_ID=$(echo "$BODY" | jq -r '.id')
|
||||
echo "Created release with ID: ${RELEASE_ID}"
|
||||
else
|
||||
echo "Failed to create release. HTTP ${HTTP_CODE}"
|
||||
echo "$BODY"
|
||||
RELEASE_ID=$(jq -r '.id // empty' release-response.json)
|
||||
if [ -z "${RELEASE_ID}" ]; then
|
||||
echo "Could not determine release ID from:"
|
||||
cat release-response.json
|
||||
exit 1
|
||||
fi
|
||||
echo "Using release ID: ${RELEASE_ID}"
|
||||
|
||||
# Upload plugin artifacts (one per supported Jellyfin generation)
|
||||
for ASSET in \
|
||||
@@ -109,9 +118,10 @@ jobs:
|
||||
-H "Authorization: token ${GITEA_TOKEN}" \
|
||||
-H "Content-Type: application/zip" \
|
||||
--data-binary "@${ASSET}" \
|
||||
"${GITEA_URL}/api/v1/repos/${REPO_OWNER}/${REPO_NAME}/releases/${RELEASE_ID}/assets?name=$(basename "${ASSET}")"
|
||||
"${API_URL}/releases/${RELEASE_ID}/assets?name=$(basename "${ASSET}")"
|
||||
done
|
||||
|
||||
rm -f release-response.json
|
||||
echo "Release created successfully!"
|
||||
echo "View at: ${GITEA_URL}/${REPO_OWNER}/${REPO_NAME}/releases/tag/${{ steps.get_version.outputs.version }}"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user