fix(ci): make release asset step resilient against set -e in Gitea Actions

This commit is contained in:
soda64 committed 2026-10-09 20:28:09 +02:00
1 parent 6f23f14b76
commit 2462bdf097
1 file changed
+5 -5
+5 -5
View File
@@ -97,7 +97,7 @@ jobs:
echo "[INFO] Ensuring Gitea Release exists for tag ${TAG_NAME}..." echo "[INFO] Ensuring Gitea Release exists for tag ${TAG_NAME}..."
REL_INFO=$(curl -k -s -H "Authorization: token ${GITEA_TOKEN}" "${API_URL}/releases/tags/${TAG_NAME}") REL_INFO=$(curl -k -s -H "Authorization: token ${GITEA_TOKEN}" "${API_URL}/releases/tags/${TAG_NAME}")
REL_ID=$(echo "$REL_INFO" | grep -o '"id":[0-9]*' | head -n 1 | cut -d: -f2) REL_ID=$(python3 -c "import sys, json; data=json.loads(sys.argv[1]); print(data.get('id', ''))" "$REL_INFO" 2>/dev/null || true)
if [[ -z "$REL_ID" || "$REL_ID" == "null" ]]; then if [[ -z "$REL_ID" || "$REL_ID" == "null" ]]; then
echo "[INFO] Creating release for tag ${TAG_NAME}..." echo "[INFO] Creating release for tag ${TAG_NAME}..."
@@ -115,7 +115,7 @@ jobs:
-H "Content-Type: application/json" \ -H "Content-Type: application/json" \
-d "$CREATE_PAYLOAD" \ -d "$CREATE_PAYLOAD" \
"${API_URL}/releases") "${API_URL}/releases")
REL_ID=$(echo "$NEW_REL" | grep -o '"id":[0-9]*' | head -n 1 | cut -d: -f2) REL_ID=$(python3 -c "import sys, json; data=json.loads(sys.argv[1]); print(data.get('id', ''))" "$NEW_REL" 2>/dev/null || true)
fi fi
echo "[INFO] Release ID: ${REL_ID}" echo "[INFO] Release ID: ${REL_ID}"
@@ -127,11 +127,11 @@ jobs:
echo "[INFO] Uploading asset: ${FNAME}..." echo "[INFO] Uploading asset: ${FNAME}..."
# Delete existing asset with same name if present # Delete existing asset with same name if present
EXISTING_ASSETS=$(curl -k -s -H "Authorization: token ${GITEA_TOKEN}" "${API_URL}/releases/${REL_ID}/assets") EXISTING_ASSETS=$(curl -k -s -H "Authorization: token ${GITEA_TOKEN}" "${API_URL}/releases/${REL_ID}/assets" || echo "[]")
ASSET_ID=$(echo "$EXISTING_ASSETS" | grep -B 2 "\"name\":\"${FNAME}\"" | grep -o '"id":[0-9]*' | head -n 1 | cut -d: -f2 || true) ASSET_ID=$(python3 -c "import sys, json; assets=json.loads(sys.argv[1]) if sys.argv[1] else []; fname=sys.argv[2]; print(next((str(a['id']) for a in assets if isinstance(a, dict) and a.get('name') == fname), ''))" "$EXISTING_ASSETS" "$FNAME" 2>/dev/null || true)
if [[ -n "$ASSET_ID" ]]; then if [[ -n "$ASSET_ID" ]]; then
echo "[INFO] Deleting existing asset ${FNAME} (ID: ${ASSET_ID})..." echo "[INFO] Deleting existing asset ${FNAME} (ID: ${ASSET_ID})..."
curl -k -s -X DELETE -H "Authorization: token ${GITEA_TOKEN}" "${API_URL}/releases/${REL_ID}/assets/${ASSET_ID}" curl -k -s -X DELETE -H "Authorization: token ${GITEA_TOKEN}" "${API_URL}/releases/${REL_ID}/assets/${ASSET_ID}" || true
fi fi
# Upload asset # Upload asset