feat: check and delete existing release before creating a new one
Beta Release / deploy (push) Successful in 1m5s
Beta Release / deploy (push) Successful in 1m5s
This commit is contained in:
@@ -79,6 +79,21 @@ jobs:
|
||||
TAG="${{ gitea.ref_name }}"
|
||||
API="${{ gitea.server_url }}/api/v1"
|
||||
|
||||
# 0. Check & Delete Existing Release
|
||||
echo "=== 0. Check & Delete Existing Release ==="
|
||||
EXISTING_RESP=$(curl -s -H "Authorization: token $TOKEN" "$API/repos/$REPO/releases/tags/$TAG")
|
||||
EXISTING_ID=$(echo "$EXISTING_RESP" | grep -o '"id":[0-9]*' | head -n 1 | cut -d':' -f2 || true)
|
||||
|
||||
if [ -n "$EXISTING_ID" ] && [ "$EXISTING_ID" != "null" ]; then
|
||||
echo "⚠️ Found existing release for tag $TAG with ID: $EXISTING_ID. Deleting..."
|
||||
DELETE_RESP=$(curl -s -w "\n%{http_code}" -X DELETE -H "Authorization: token $TOKEN" "$API/repos/$REPO/releases/$EXISTING_ID")
|
||||
echo "✅ Delete response: $DELETE_RESP"
|
||||
else
|
||||
echo "No existing release found for $TAG. Proceeding..."
|
||||
fi
|
||||
|
||||
# 1. Create Release
|
||||
echo "=== 1. Create New Release ==="
|
||||
JSON_BODY=$(printf '{"tag_name":"%s","name":"%s","body":"Release %s","draft":false,"prerelease":%s}' "$TAG" "$TAG" "$TAG" "${{ inputs.prerelease }}")
|
||||
|
||||
RELEASE_RESP=$(curl -s -X POST \
|
||||
|
||||
Reference in New Issue
Block a user