From 6b9074241faa7020027fd58244392aa29342334b Mon Sep 17 00:00:00 2001 From: "Aleksei (Faumaray) Selikhov" Date: Sun, 6 Dec 2026 15:10:45 +0300 Subject: [PATCH] ci(release): keep the release payload valid JSON The release body embedded literal newlines, so the create-release POST was rejected; it only ever worked because an existing release was found by tag. Escape the newlines, validate the payload, and print the server responses when no release id can be resolved. --- .gitea/workflows/ci.yml | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/.gitea/workflows/ci.yml b/.gitea/workflows/ci.yml index 27b7c43..bee1eb0 100644 --- a/.gitea/workflows/ci.yml +++ b/.gitea/workflows/ci.yml @@ -475,9 +475,11 @@ jobs: (cd dist && sha256sum ./* > SHA256SUMS) ls -l dist/ api="${GITHUB_SERVER_URL}/api/v1/repos/${GITHUB_REPOSITORY}" - body="$(printf 'Release %s\n\nBuilt from %s with the full CTest suite green.\nSee SHA256SUMS for artifact digests.' "${tag}" "${GITHUB_SHA}")" + # Escaped newlines: the payload must stay valid JSON. + body="$(printf 'Release %s\\n\\nBuilt from %s with the full CTest suite green.\\nSee SHA256SUMS for artifact digests.' "${tag}" "${GITHUB_SHA}")" payload="$(printf '{"tag_name":"%s","name":"%s","body":"%s","draft":false,"prerelease":false}' \ "${tag}" "${tag}" "${body}")" + printf '%s' "${payload}" | python3 -c 'import json,sys; json.load(sys.stdin)' extract_id() { python3 -c 'import json,sys; s=sys.stdin.read().strip(); print(json.loads(s).get("id","") if s else "")' 2>/dev/null || true } @@ -490,7 +492,12 @@ jobs: "${api}/releases/tags/${tag}" || true)" release_id="$(printf '%s' "${existing}" | extract_id)" fi - test -n "${release_id}" + if [ -z "${release_id}" ]; then + echo "could not create or find the release for ${tag}:" >&2 + echo "create: ${created}" >&2 + echo "lookup: ${existing:-}" >&2 + exit 1 + fi for file in dist/*; do name="$(basename "${file}")" curl -fsS -X POST -H "Authorization: token ${TOKEN}" \