diff --git a/.gitea/workflows/release.yml b/.gitea/workflows/release.yml index 4f121c6..fa56fa1 100644 --- a/.gitea/workflows/release.yml +++ b/.gitea/workflows/release.yml @@ -41,11 +41,20 @@ jobs: id: create_release run: | TAG="${{ github.ref_name }}" + API="${{ github.server_url }}/api/v1/repos/${{ github.repository }}" + AUTH="Authorization: token ${{ secrets.GITEA_TOKEN }}" + + # Delete existing release for this tag if present + EXISTING=$(curl -sf -H "$AUTH" "$API/releases/tags/$TAG" | python3 -c "import sys,json; print(json.load(sys.stdin).get('id',''))" 2>/dev/null || true) + if [ -n "$EXISTING" ]; then + echo "Deleting existing release $EXISTING" + curl -sf -X DELETE -H "$AUTH" "$API/releases/$EXISTING" + fi RELEASE=$(curl -sf -X POST \ - -H "Authorization: token ${{ secrets.GITEA_TOKEN }}" \ + -H "$AUTH" \ -H "Content-Type: application/json" \ - "${{ github.server_url }}/api/v1/repos/${{ github.repository }}/releases" \ + "$API/releases" \ -d "{ \"tag_name\": \"$TAG\", \"name\": \"$TAG\",