From 13f9fd642cab7469b974ca9fe47a2ff9ac57f472 Mon Sep 17 00:00:00 2001 From: Karol Labus Date: Thu, 17 Sep 2026 21:05:29 +0200 Subject: [PATCH] fix: make Gitea release step idempotent in workflow --- .gitea/workflows/release.yml | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/.gitea/workflows/release.yml b/.gitea/workflows/release.yml index 3565e28..ee69d70 100644 --- a/.gitea/workflows/release.yml +++ b/.gitea/workflows/release.yml @@ -58,22 +58,26 @@ jobs: IS_PRERELEASE="true" fi - # Create Release - RELEASE_RES=$(curl -s -X POST "$API_URL/repos/$REPO/releases" \ - -H "Authorization: token $TOKEN" \ - -H "Content-Type: application/json" \ - -d "{\"tag_name\":\"$TAG\", \"name\":\"Release $TAG\", \"body\":\"Automated release\", \"draft\":false, \"prerelease\":$IS_PRERELEASE}") + # Check if release exists + EXISTING_REL=$(curl -s -H "Authorization: token $TOKEN" "$API_URL/repos/$REPO/releases/tags/$TAG") + REL_ID=$(echo "$EXISTING_REL" | grep -o '"id":[0-9]*' | head -1 | cut -d':' -f2) - REL_ID=$(echo "$RELEASE_RES" | grep -o '"id":[0-9]*' | head -1 | cut -d':' -f2) + if [ -z "$REL_ID" ] || [ "$REL_ID" == "null" ]; then + RELEASE_RES=$(curl -s -X POST "$API_URL/repos/$REPO/releases" \ + -H "Authorization: token $TOKEN" \ + -H "Content-Type: application/json" \ + -d "{\"tag_name\":\"$TAG\", \"name\":\"Release $TAG\", \"body\":\"Automated release\", \"draft\":false, \"prerelease\":$IS_PRERELEASE}") + REL_ID=$(echo "$RELEASE_RES" | grep -o '"id":[0-9]*' | head -1 | cut -d':' -f2) + fi # Upload Assets curl -s -X POST "$API_URL/repos/$REPO/releases/$REL_ID/assets" \ -H "Authorization: token $TOKEN" \ - -F "attachment=@BlackBarRemover_${TAG}_jf10.11.zip" + -F "attachment=@BlackBarRemover_${TAG}_jf10.11.zip" || true curl -s -X POST "$API_URL/repos/$REPO/releases/$REL_ID/assets" \ -H "Authorization: token $TOKEN" \ - -F "attachment=@BlackBarRemover_${TAG}_jf12.0.zip" + -F "attachment=@BlackBarRemover_${TAG}_jf12.0.zip" || true - name: Update manifest.json run: |