From 2df3c17936f4de2cd40ed877798adc50c1a450e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=A8=E6=9F=B3=E6=9D=B0?= Date: Mon, 4 May 2026 17:40:08 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20CI=E5=85=88=E6=B8=85=E7=90=86=E6=97=A7Re?= =?UTF-8?q?lease=E5=86=8D=E5=88=9B=E5=BB=BA=EF=BC=8C=E9=81=BF=E5=85=8D?= =?UTF-8?q?=E9=87=8D=E5=A4=8D=E5=86=B2=E7=AA=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Opus 4.6 --- .gitea/workflows/release-docs.yml | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/.gitea/workflows/release-docs.yml b/.gitea/workflows/release-docs.yml index aaf781e..ab613cd 100644 --- a/.gitea/workflows/release-docs.yml +++ b/.gitea/workflows/release-docs.yml @@ -28,10 +28,19 @@ jobs: run: | TAG=${GITHUB_REF#refs/tags/} API="${{ github.server_url }}/api/v1/repos/${{ github.repository }}" + AUTH="Authorization: token ${GITEA_TOKEN}" + + # Delete existing release for this tag if any (ignore errors) + EXISTING_ID=$(curl -sf "${API}/releases/tags/${TAG}" -H "$AUTH" 2>/dev/null \ + | python3 -c "import sys,json; print(json.load(sys.stdin).get('id',''))" 2>/dev/null || true) + if [ -n "$EXISTING_ID" ]; then + echo "Deleting existing release #${EXISTING_ID}" + curl -sf -X DELETE "${API}/releases/${EXISTING_ID}" -H "$AUTH" 2>/dev/null || true + fi # Create release curl -sf -X POST "${API}/releases" \ - -H "Authorization: token ${GITEA_TOKEN}" \ + -H "$AUTH" \ -H "Content-Type: application/json" \ -d "{ \"tag_name\": \"${TAG}\", @@ -39,9 +48,8 @@ jobs: \"body\": \"米普云航司API文档更新 ${TAG}\" }" - # Get release ID via python (no jq dependency) - RELEASE_ID=$(curl -sf "${API}/releases/tags/${TAG}" \ - -H "Authorization: token ${GITEA_TOKEN}" \ + # Get release ID + RELEASE_ID=$(curl -sf "${API}/releases/tags/${TAG}" -H "$AUTH" \ | python3 -c "import sys,json; print(json.load(sys.stdin)['id'])") if [ -z "$RELEASE_ID" ] || [ "$RELEASE_ID" = "None" ]; then @@ -49,10 +57,11 @@ jobs: exit 1 fi + echo "Release #${RELEASE_ID} created" + # Upload docs.tar.gz curl -sf -X POST "${API}/releases/${RELEASE_ID}/assets?name=docs.tar.gz" \ - -H "Authorization: token ${GITEA_TOKEN}" \ - -H "Content-Type: multipart/form-data" \ + -H "$AUTH" \ -F "attachment=@/tmp/docs.tar.gz" echo "Release ${TAG} created with docs.tar.gz"