Compare commits
2 Commits
v1.0.0
...
debug-release
| Author | SHA1 | Date | |
|---|---|---|---|
| a799af3d54 | |||
| 981506c96c |
+17
-117
@@ -1,129 +1,29 @@
|
||||
name: Release
|
||||
name: Debug Release API
|
||||
|
||||
on:
|
||||
push:
|
||||
tags:
|
||||
- 'v*'
|
||||
|
||||
permissions:
|
||||
contents: write
|
||||
branches:
|
||||
- debug-release
|
||||
|
||||
jobs:
|
||||
build-and-release:
|
||||
debug-api:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Clone repository with submodules
|
||||
- name: Debug token and API
|
||||
run: |
|
||||
git config --global --remove-section http || true
|
||||
git config --global --unset-all core.askPass || true
|
||||
TOKEN="${{ secrets.TOKEN_BUILD }}"
|
||||
git clone --recurse-submodules \
|
||||
-c credential.helper="" \
|
||||
https://token:$TOKEN@git.datadunia.com/devops/wireguard-vpn.git .
|
||||
|
||||
- name: Setup Go
|
||||
uses: actions/setup-go@v5
|
||||
with:
|
||||
go-version: '1.22'
|
||||
|
||||
- name: Setup Node.js
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: '20'
|
||||
|
||||
- name: Build Vue frontend
|
||||
run: |
|
||||
cd app/frontend
|
||||
npm install
|
||||
npm run build
|
||||
|
||||
- name: Build Go binaries
|
||||
run: |
|
||||
cd app
|
||||
GOOS=linux GOARCH=amd64 go build -o ../wgrplane-linux-amd64 .
|
||||
GOOS=linux GOARCH=arm64 go build -o ../wgrplane-linux-arm64 .
|
||||
|
||||
- name: Generate latest.json
|
||||
run: |
|
||||
VERSION="${{ gitea.ref_name }}"
|
||||
RELEASE_DATE="$(date -u +'%Y-%m-%dT%H:%M:%SZ')"
|
||||
TOKEN="${{ secrets.BUILD_TOKEN }}"
|
||||
REPO="${{ gitea.repository }}"
|
||||
SERVER="${{ gitea.server_url }}"
|
||||
cat > latest.json << ENDJSON
|
||||
{
|
||||
"version": "$VERSION",
|
||||
"release_date": "$RELEASE_DATE",
|
||||
"download_urls": {
|
||||
"amd64": "${SERVER}/${REPO}/releases/download/${VERSION}/wgrplane-linux-amd64",
|
||||
"arm64": "${SERVER}/${REPO}/releases/download/${VERSION}/wgrplane-linux-arm64"
|
||||
}
|
||||
}
|
||||
ENDJSON
|
||||
API="${{ gitea.server_url }}/api/v1"
|
||||
|
||||
- name: Create Release and upload assets
|
||||
env:
|
||||
TOKEN: ${{ secrets.TOKEN_BUILD }} # <--- Tambahkan ini
|
||||
run: |
|
||||
if [ -z "$TOKEN" ]; then
|
||||
echo "❌ ERROR: Secret TOKEN_BUILD tidak terbaca oleh runner!"
|
||||
exit 1
|
||||
else
|
||||
echo "✅ Secret terbaca (panjang karakter: ${#TOKEN})"
|
||||
fi
|
||||
# # Gunakan variabel bawaan Gitea Actions untuk keandalan
|
||||
# REPO="${{ gitea.repository }}"
|
||||
# TAG="${{ gitea.ref_name }}"
|
||||
# API="${{ gitea.server_url }}/api/v1"
|
||||
echo "=== 1. Token check ==="
|
||||
echo "Token length: ${#TOKEN}"
|
||||
echo "Token first 6: ${TOKEN:0:6}"
|
||||
echo "Token last 4: ${TOKEN: -4}"
|
||||
|
||||
# echo "Menciptakan release untuk tag: $TAG"
|
||||
echo "=== 2. GET /user (auth test) ==="
|
||||
curl -sv -H "Authorization: token $TOKEN" "$API/user" 2>&1 | head -30
|
||||
|
||||
# # 1. Create Release
|
||||
# # Menggunakan -w "%{http_code}" untuk debugging jika gagal
|
||||
# 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")
|
||||
|
||||
# # 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
|
||||
if: always()
|
||||
run: |
|
||||
git config --global --remove-section http || true
|
||||
git config --global --unset-all core.askPass || true
|
||||
rm -f wgrplane-linux-amd64 wgrplane-linux-arm64 latest.json
|
||||
rm -rf app/frontend/node_modules app/frontend/dist
|
||||
echo "Cleanup done"
|
||||
echo "=== 3. GET releases list ==="
|
||||
curl -s -w "\nHTTP_CODE:%{http_code}" \
|
||||
-H "Authorization: token $TOKEN" \
|
||||
"$API/repos/$REPO/releases"
|
||||
|
||||
Reference in New Issue
Block a user