From 95bb71b60f5dd040ca605ff9755ac86d095c94c1 Mon Sep 17 00:00:00 2001 From: MiTHRAL Date: Wed, 22 Apr 2026 18:09:04 -0400 Subject: [PATCH] ci: fix release asset upload to use multipart form, handle existing releases --- .github/workflows/build.yml | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index d83db3c..96aa9c1 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -42,14 +42,22 @@ jobs: GITEA_TOKEN: ${{ secrets.GITHUB_TOKEN }} TAG: ${{ github.ref_name }} run: | - RESPONSE=$(curl -sf -X POST \ - "https://git.mithraic.cloud/api/v1/repos/ad3laid3/sanctum/releases" \ - -H "Authorization: token $GITEA_TOKEN" \ - -H "Content-Type: application/json" \ - -d "{\"tag_name\":\"$TAG\",\"name\":\"Sanctum $TAG\",\"draft\":false,\"prerelease\":false}") - + # Reuse existing release if already created (handles re-runs) + RESPONSE=$(curl -s \ + "https://git.mithraic.cloud/api/v1/repos/ad3laid3/sanctum/releases/tags/$TAG" \ + -H "Authorization: token $GITEA_TOKEN") RELEASE_ID=$(echo "$RESPONSE" | grep -o '"id":[0-9]*' | head -1 | grep -o '[0-9]*') - echo "Created release ID: $RELEASE_ID" + + if [ -z "$RELEASE_ID" ]; then + RESPONSE=$(curl -sf -X POST \ + "https://git.mithraic.cloud/api/v1/repos/ad3laid3/sanctum/releases" \ + -H "Authorization: token $GITEA_TOKEN" \ + -H "Content-Type: application/json" \ + -d "{\"tag_name\":\"$TAG\",\"name\":\"Sanctum $TAG\",\"draft\":false,\"prerelease\":false}") + RELEASE_ID=$(echo "$RESPONSE" | grep -o '"id":[0-9]*' | head -1 | grep -o '[0-9]*') + fi + + echo "Release ID: $RELEASE_ID" find out/make -type f -name "*.zip" | while read FILE; do NAME=$(basename "$FILE") @@ -57,6 +65,5 @@ jobs: curl -sf -X POST \ "https://git.mithraic.cloud/api/v1/repos/ad3laid3/sanctum/releases/$RELEASE_ID/assets?name=$NAME" \ -H "Authorization: token $GITEA_TOKEN" \ - -H "Content-Type: application/octet-stream" \ - --data-binary "@$FILE" + -F "attachment=@$FILE" done