Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -28,10 +28,19 @@ jobs:
|
|||||||
run: |
|
run: |
|
||||||
TAG=${GITHUB_REF#refs/tags/}
|
TAG=${GITHUB_REF#refs/tags/}
|
||||||
API="${{ github.server_url }}/api/v1/repos/${{ github.repository }}"
|
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
|
# Create release
|
||||||
curl -sf -X POST "${API}/releases" \
|
curl -sf -X POST "${API}/releases" \
|
||||||
-H "Authorization: token ${GITEA_TOKEN}" \
|
-H "$AUTH" \
|
||||||
-H "Content-Type: application/json" \
|
-H "Content-Type: application/json" \
|
||||||
-d "{
|
-d "{
|
||||||
\"tag_name\": \"${TAG}\",
|
\"tag_name\": \"${TAG}\",
|
||||||
@@ -39,9 +48,8 @@ jobs:
|
|||||||
\"body\": \"米普云航司API文档更新 ${TAG}\"
|
\"body\": \"米普云航司API文档更新 ${TAG}\"
|
||||||
}"
|
}"
|
||||||
|
|
||||||
# Get release ID via python (no jq dependency)
|
# Get release ID
|
||||||
RELEASE_ID=$(curl -sf "${API}/releases/tags/${TAG}" \
|
RELEASE_ID=$(curl -sf "${API}/releases/tags/${TAG}" -H "$AUTH" \
|
||||||
-H "Authorization: token ${GITEA_TOKEN}" \
|
|
||||||
| python3 -c "import sys,json; print(json.load(sys.stdin)['id'])")
|
| python3 -c "import sys,json; print(json.load(sys.stdin)['id'])")
|
||||||
|
|
||||||
if [ -z "$RELEASE_ID" ] || [ "$RELEASE_ID" = "None" ]; then
|
if [ -z "$RELEASE_ID" ] || [ "$RELEASE_ID" = "None" ]; then
|
||||||
@@ -49,10 +57,11 @@ jobs:
|
|||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
echo "Release #${RELEASE_ID} created"
|
||||||
|
|
||||||
# Upload docs.tar.gz
|
# Upload docs.tar.gz
|
||||||
curl -sf -X POST "${API}/releases/${RELEASE_ID}/assets?name=docs.tar.gz" \
|
curl -sf -X POST "${API}/releases/${RELEASE_ID}/assets?name=docs.tar.gz" \
|
||||||
-H "Authorization: token ${GITEA_TOKEN}" \
|
-H "$AUTH" \
|
||||||
-H "Content-Type: multipart/form-data" \
|
|
||||||
-F "attachment=@/tmp/docs.tar.gz"
|
-F "attachment=@/tmp/docs.tar.gz"
|
||||||
|
|
||||||
echo "Release ${TAG} created with docs.tar.gz"
|
echo "Release ${TAG} created with docs.tar.gz"
|
||||||
|
|||||||
Reference in New Issue
Block a user