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

This commit is contained in:
datadunia
2026-05-08 04:55:29 +07:00
parent b9fbe1430f
commit 45c7788d1d
+24 -53
View File
@@ -61,63 +61,34 @@ jobs:
ENDJSON ENDJSON
- name: Create Release and upload assets - name: Create Release and upload assets
env:
TOKEN: ${{ secrets.TOKEN_BUILD }} # <--- Tambahkan ini
run: | run: |
if [ -z "$TOKEN" ]; then TOKEN="${{ secrets.TOKEN_BUILD }}"
echo "❌ ERROR: Secret TOKEN_BUILD tidak terbaca oleh runner!" REPO="${{ gitea.repository }}"
TAG="${{ gitea.ref_name }}"
API="${{ gitea.server_url }}/api/v1"
JSON_BODY=$(printf '{"tag_name":"%s","name":"%s","body":"Release %s","draft":false,"prerelease":false}' "$TAG" "$TAG" "$TAG")
RELEASE_RESP=$(curl -s -X POST \
-H "Authorization: token $TOKEN" \
-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"
exit 1 exit 1
else
echo "✅ Secret terbaca (panjang karakter: ${#TOKEN})"
fi fi
# # Gunakan variabel bawaan Gitea Actions untuk keandalan
# REPO="${{ gitea.repository }}"
# TAG="${{ gitea.ref_name }}"
# API="${{ gitea.server_url }}/api/v1"
# echo "Menciptakan release untuk tag: $TAG" for FILE in wgrplane-linux-amd64 wgrplane-linux-arm64 latest.json; do
echo "Uploading $FILE..."
# # 1. Create Release curl -s -X POST \
# # Menggunakan -w "%{http_code}" untuk debugging jika gagal -H "Authorization: token $TOKEN" \
# JSON_BODY=$(printf '{"tag_name":"%s","name":"%s","body":"Release %s","draft":false,"prerelease":false}' "$TAG" "$TAG" "$TAG") -F "attachment=@$FILE" \
"$API/repos/$REPO/releases/$RELEASE_ID/assets?name=$FILE"
# RELEASE_RESP=$(curl -s -X POST \ done
# -H "Authorization: token $TOKEN" \
# -H "Content-Type: application/json" \
# -d "$JSON_BODY" \
# "$API/repos/$REPO/releases")
# # Cara lebih aman ambil ID (menghapus "id": dan tanda koma)
# RELEASE_ID=$(echo "$RELEASE_RESP" | grep -o '"id":[0-9]*' | cut -d':' -f2)
# if [ -z "$RELEASE_ID" ] || [ "$RELEASE_ID" = "null" ]; then
# echo "Gagal membuat release. Response: $RELEASE_RESP"
# exit 1
# fi
# echo "Release berhasil dibuat dengan ID: $RELEASE_ID"
# # 2. Upload 3 File menggunakan loop
# # Sesuai Swagger: POST /repos/{owner}/{repo}/releases/{id}/assets
# for FILE in wgrplane-linux-amd64 wgrplane-linux-arm64 latest.json; do
# if [ -f "$FILE" ]; then
# echo "Sedang mengupload: $FILE..."
# UPLOAD_STATUS=$(curl -s -o /dev/null -w "%{http_code}" -X POST \
# -H "Authorization: token $TOKEN" \
# -F "attachment=@$FILE" \
# "$API/repos/$REPO/releases/$RELEASE_ID/assets?name=$FILE")
# if [ "$UPLOAD_STATUS" == "201" ]; then
# echo "Berhasil upload $FILE"
# else
# echo "Gagal upload $FILE (HTTP Status: $UPLOAD_STATUS)"
# exit 1
# fi
# else
# echo "Error: File $FILE tidak ditemukan di direktori!"
# exit 1
# fi
# done
- name: Cleanup build artifacts - name: Cleanup build artifacts
if: always() if: always()