From 21bfdce27a1e8ecd3d37bd2d327cc4c096e265d4 Mon Sep 17 00:00:00 2001 From: Julian Cuni Date: Thu, 3 Sep 2026 10:50:36 +0200 Subject: [PATCH] fix(release): surface the actual Gitea API error on mirror failure MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The mirror step's release id came back empty on the last real run but nothing failed loudly — every curl response was swallowed (|| true, or piped straight to /dev/null), so we had no idea why. Capture HTTP status + response body on every call and exit 1 with the actual error instead of silently uploading to a malformed //assets URL with no release id. --- .gitea/workflows/release.yml | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/.gitea/workflows/release.yml b/.gitea/workflows/release.yml index 146b676..a9931e7 100644 --- a/.gitea/workflows/release.yml +++ b/.gitea/workflows/release.yml @@ -196,16 +196,22 @@ jobs: set -e create_or_get_release() { local mirror_tag="$1" prerelease="$2" - REL=$(curl -sS -X POST \ + REL=$(curl -sS -w '\n%{http_code}' -X POST \ -H "Authorization: token ${TOKEN}" \ -H "Content-Type: application/json" \ -d "{\"tag_name\":\"${mirror_tag}\",\"name\":\"Parking System ${TAG}\",\"draft\":false,\"prerelease\":${prerelease}}" \ "${API}/repos/${MIRROR_REPO}/releases" || true) + echo "create response (${mirror_tag}): ${REL}" REL_ID=$(printf '%s' "$REL" | grep -o '"id":[0-9]*' | head -1 | cut -d: -f2 || true) if [ -z "$REL_ID" ]; then - REL_ID=$(curl -sS -H "Authorization: token ${TOKEN}" \ - "${API}/repos/${MIRROR_REPO}/releases/tags/${mirror_tag}" \ - | grep -o '"id":[0-9]*' | head -1 | cut -d: -f2 || true) + LOOKUP=$(curl -sS -w '\n%{http_code}' -H "Authorization: token ${TOKEN}" \ + "${API}/repos/${MIRROR_REPO}/releases/tags/${mirror_tag}") + echo "tag lookup response (${mirror_tag}): ${LOOKUP}" + REL_ID=$(printf '%s' "$LOOKUP" | grep -o '"id":[0-9]*' | head -1 | cut -d: -f2 || true) + fi + if [ -z "$REL_ID" ]; then + echo "::error::could not create or find release for tag ${mirror_tag} on ${MIRROR_REPO} — see responses above" + exit 1 fi } upload_assets() { @@ -213,11 +219,15 @@ jobs: for f in dist/*; do name=$(basename "$f") echo "mirroring ${name} -> release ${rel_id}" - curl -sS -X POST \ + HTTP_CODE=$(curl -sS -o /tmp/upload_resp.json -w '%{http_code}' -X POST \ -H "Authorization: token ${TOKEN}" \ -H "Content-Type: application/octet-stream" \ --data-binary @"${f}" \ - "${API}/repos/${MIRROR_REPO}/releases/${rel_id}/assets?name=${name}" >/dev/null + "${API}/repos/${MIRROR_REPO}/releases/${rel_id}/assets?name=${name}") + if [ "$HTTP_CODE" -ge 300 ]; then + echo "::error::upload of ${name} failed (HTTP ${HTTP_CODE}): $(cat /tmp/upload_resp.json)" + exit 1 + fi done }