fix: restore Create Release step with correct Swagger-compliant JSON and auth header
Release / build-and-release (push) Failing after 54s

This commit is contained in:
datadunia
2026-05-08 05:00:55 +07:00
parent 45c7788d1d
commit 565d7f1a35
+26 -5
View File
@@ -61,12 +61,25 @@ jobs:
ENDJSON
- name: Create Release and upload assets
env:
# PINDAHKAN TOKEN KE SINI
TOKEN: ${{ secrets.TOKEN_BUILD }}
run: |
TOKEN="${{ secrets.TOKEN_BUILD }}"
# Sekarang $TOKEN sudah bisa dipakai di Bash
echo "--- Diagnostic ---"
if [ -z "$TOKEN" ]; then
echo "Value: [EMPTY]"
exit 1
else
echo "Length: ${#TOKEN} characters"
fi
REPO="${{ gitea.repository }}"
TAG="${{ gitea.ref_name }}"
API="${{ gitea.server_url }}/api/v1"
# 1. Create Release
JSON_BODY=$(printf '{"tag_name":"%s","name":"%s","body":"Release %s","draft":false,"prerelease":false}' "$TAG" "$TAG" "$TAG")
RELEASE_RESP=$(curl -s -X POST \
@@ -74,20 +87,28 @@ jobs:
-H "Content-Type: application/json" \
-d "$JSON_BODY" \
"$API/repos/$REPO/releases")
echo "Release response: $RELEASE_RESP"
RELEASE_ID=$(echo "$RELEASE_RESP" | grep -o '"id":[0-9]*' | head -1 | grep -o '[0-9]*')
if [ -z "$RELEASE_ID" ]; then
echo "Failed to create release"
# Ambil ID dengan lebih teliti
RELEASE_ID=$(echo "$RELEASE_RESP" | grep -o '"id":[0-9]*' | head -n 1 | cut -d':' -f2)
if [ -z "$RELEASE_ID" ] || [ "$RELEASE_ID" = "null" ]; then
echo "Gagal membuat release. Response: $RELEASE_RESP"
exit 1
fi
echo "Release ID: $RELEASE_ID"
# 2. Upload Assets
for FILE in wgrplane-linux-amd64 wgrplane-linux-arm64 latest.json; do
if [ -f "$FILE" ]; then
echo "Uploading $FILE..."
curl -s -X POST \
-H "Authorization: token $TOKEN" \
-F "attachment=@$FILE" \
"$API/repos/$REPO/releases/$RELEASE_ID/assets?name=$FILE"
else
echo "Skip $FILE (tidak ditemukan)"
fi
done
- name: Cleanup build artifacts