fix: make Gitea release step idempotent in workflow
Build and Release Plugin / release (push) Successful in 34s
Build and Release Plugin / release (push) Successful in 34s
This commit is contained in:
@@ -58,22 +58,26 @@ jobs:
|
||||
IS_PRERELEASE="true"
|
||||
fi
|
||||
|
||||
# Create Release
|
||||
RELEASE_RES=$(curl -s -X POST "$API_URL/repos/$REPO/releases" \
|
||||
-H "Authorization: token $TOKEN" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d "{\"tag_name\":\"$TAG\", \"name\":\"Release $TAG\", \"body\":\"Automated release\", \"draft\":false, \"prerelease\":$IS_PRERELEASE}")
|
||||
# Check if release exists
|
||||
EXISTING_REL=$(curl -s -H "Authorization: token $TOKEN" "$API_URL/repos/$REPO/releases/tags/$TAG")
|
||||
REL_ID=$(echo "$EXISTING_REL" | grep -o '"id":[0-9]*' | head -1 | cut -d':' -f2)
|
||||
|
||||
REL_ID=$(echo "$RELEASE_RES" | grep -o '"id":[0-9]*' | head -1 | cut -d':' -f2)
|
||||
if [ -z "$REL_ID" ] || [ "$REL_ID" == "null" ]; then
|
||||
RELEASE_RES=$(curl -s -X POST "$API_URL/repos/$REPO/releases" \
|
||||
-H "Authorization: token $TOKEN" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d "{\"tag_name\":\"$TAG\", \"name\":\"Release $TAG\", \"body\":\"Automated release\", \"draft\":false, \"prerelease\":$IS_PRERELEASE}")
|
||||
REL_ID=$(echo "$RELEASE_RES" | grep -o '"id":[0-9]*' | head -1 | cut -d':' -f2)
|
||||
fi
|
||||
|
||||
# Upload Assets
|
||||
curl -s -X POST "$API_URL/repos/$REPO/releases/$REL_ID/assets" \
|
||||
-H "Authorization: token $TOKEN" \
|
||||
-F "attachment=@BlackBarRemover_${TAG}_jf10.11.zip"
|
||||
-F "attachment=@BlackBarRemover_${TAG}_jf10.11.zip" || true
|
||||
|
||||
curl -s -X POST "$API_URL/repos/$REPO/releases/$REL_ID/assets" \
|
||||
-H "Authorization: token $TOKEN" \
|
||||
-F "attachment=@BlackBarRemover_${TAG}_jf12.0.zip"
|
||||
-F "attachment=@BlackBarRemover_${TAG}_jf12.0.zip" || true
|
||||
|
||||
- name: Update manifest.json
|
||||
run: |
|
||||
|
||||
Reference in New Issue
Block a user