From 4ad2743f8ab3e41f051fafd52e78a107d2699ad7 Mon Sep 17 00:00:00 2001 From: marauder-actual Date: Fri, 12 Jun 2026 17:51:16 +0200 Subject: [PATCH] Handle existing releases gracefully, validate release IDs --- .gitea/workflows/build.yml | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/.gitea/workflows/build.yml b/.gitea/workflows/build.yml index 600a624..86c7956 100644 --- a/.gitea/workflows/build.yml +++ b/.gitea/workflows/build.yml @@ -36,7 +36,16 @@ jobs: DEB=$(ls build/*.deb) FILENAME=$(basename "${DEB}") - # Create release (ignore conflict if exists) + # Delete existing release for this tag if any + OLD_ID=$(curl -s -H "Authorization: token ${TOKEN}" \ + "${API}/repos/${REPO}/releases/tags/${TAG}" | jq -r '.id // empty') + if [ -n "${OLD_ID}" ] && [ "${OLD_ID}" != "null" ]; then + echo "Deleting existing release ${OLD_ID}..." + curl -s -X DELETE -H "Authorization: token ${TOKEN}" \ + "${API}/repos/${REPO}/releases/${OLD_ID}" + fi + + # Create release RELEASE_ID=$(curl -s -X POST \ -H "Authorization: token ${TOKEN}" \ -H "Content-Type: application/json" \ @@ -44,6 +53,11 @@ jobs: "${API}/repos/${REPO}/releases" | jq -r '.id') echo "Release ID: ${RELEASE_ID}" + if [ -z "${RELEASE_ID}" ] || [ "${RELEASE_ID}" = "null" ]; then + echo "ERROR: Failed to create release" + exit 1 + fi + # Attach amd64 deb curl --fail -X POST \ -H "Authorization: token ${TOKEN}" \ @@ -88,6 +102,11 @@ jobs: "${API}/repos/${REPO}/releases/tags/${TAG}" | jq -r '.id') echo "Release ID: ${RELEASE_ID}" + if [ -z "${RELEASE_ID}" ] || [ "${RELEASE_ID}" = "null" ]; then + echo "ERROR: Release not found for tag ${TAG}" + exit 1 + fi + # Attach arm64 deb curl --fail -X POST \ -H "Authorization: token ${TOKEN}" \