From d0d529450cd0ab5f6a30011e1170d1566b607c5a Mon Sep 17 00:00:00 2001 From: datadunia Date: Fri, 8 May 2026 01:35:05 +0700 Subject: [PATCH] fix: use softprops/action-gh-release and add cleanup step --- .gitea/workflows/release.yaml | 69 +++++++++++++++-------------------- 1 file changed, 29 insertions(+), 40 deletions(-) diff --git a/.gitea/workflows/release.yaml b/.gitea/workflows/release.yaml index 3e357a3..3e723c1 100644 --- a/.gitea/workflows/release.yaml +++ b/.gitea/workflows/release.yaml @@ -7,34 +7,20 @@ on: permissions: contents: write - actions: read jobs: - build: + build-and-release: runs-on: ubuntu-latest - strategy: - matrix: - goarch: [amd64, arm64] steps: - name: Clone repository with submodules run: | - # 1. Bersihkan semua config global agar tidak ada interferensi header git config --global --remove-section http || true git config --global --unset-all core.askPass || true - - # 2. Masukkan token ke variabel TOKEN="${{ secrets.TOKEN_BUILD }}" - - # 3. Lakukan clone dengan menyuntikkan token ke URL - # Format: https://x-token-auth:TOKEN@DOMAIN/REPO.git - # Kita gunakan -c credential.helper="" agar git tidak mencari password di sistem git clone --recurse-submodules \ -c credential.helper="" \ https://x-token-auth:$TOKEN@git.datadunia.com/devops/wireguard-vpn.git . - # - name: Debug Submodule Folder - # run: | - # ls -la app/ - # ls -la app/frontend || echo "Frontend folder not found" + - name: Setup Go uses: actions/setup-go@v5 with: @@ -51,43 +37,46 @@ jobs: npm install npm run build - - name: Build Go binary - env: - GOOS: linux - GOARCH: ${{ matrix.goarch }} + - name: Build Go binaries run: | cd app - go build -o ../wgrplane-linux-${{ matrix.goarch }} . - - - name: Upload binary artifact - uses: actions/upload-artifact@v3 - with: - name: wgrplane-linux-${{ matrix.goarch }} - path: wgrplane-linux-${{ matrix.goarch }} + 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 }}" - if [ -z "$VERSION" ]; then - VERSION="$(git rev-parse --short HEAD)" - fi RELEASE_DATE="$(date -u +'%Y-%m-%dT%H:%M:%SZ')" - CHANGELOG="$(git log --oneline --no-merges $(git describe --tags --abbrev=0 2>/dev/null || echo 'HEAD~10')..HEAD 2>/dev/null || git log --oneline --no-merges -10)" - # Generate latest.json - cat > latest.json << EOF + CHANGELOG="$(git log --oneline --no-merges $(git describe --tags --abbrev=0 HEAD^ 2>/dev/null || echo 'HEAD~10')..HEAD 2>/dev/null || git log --oneline --no-merges -10)" + REPO="${{ gitea.repository }}" + SERVER="${{ gitea.server_url }}" + cat > latest.json << ENDJSON { "version": "$VERSION", "release_date": "$RELEASE_DATE", "changelog": $(echo "$CHANGELOG" | jq -R -s '.'), "download_urls": { - "amd64": "${{ gitea.server_url }}/${{ gitea.repository }}/actions/runs/${{ gitea.run_id }}/artifacts/$(curl -s -H 'Authorization: Bearer ${{ secrets.TOKEN }}' '${{ gitea.server_url }}/api/v1/repos/${{ gitea.repository }}/actions/runs/${{ gitea.run_id }}/artifacts' | jq -r '.data[] | select(.name == "wgrplane-linux-amd64") | .id')", - "arm64": "${{ gitea.server_url }}/${{ gitea.repository }}/actions/runs/${{ gitea.run_id }}/artifacts/$(curl -s -H 'Authorization: Bearer ${{ secrets.TOKEN }}' '${{ gitea.server_url }}/api/v1/repos/${{ gitea.repository }}/actions/runs/${{ gitea.run_id }}/artifacts' | jq -r '.data[] | select(.name == "wgrplane-linux-arm64") | .id')" + "amd64": "${SERVER}/${REPO}/releases/download/${VERSION}/wgrplane-linux-amd64", + "arm64": "${SERVER}/${REPO}/releases/download/${VERSION}/wgrplane-linux-arm64" } } - EOF + ENDJSON - - name: Upload latest.json artifact - uses: actions/upload-artifact@v3 + - name: Create Release + uses: softprops/action-gh-release@v2 with: - name: latest.json - path: latest.json + name: ${{ gitea.ref_name }} + generate_release_notes: true + files: | + wgrplane-linux-amd64 + wgrplane-linux-arm64 + latest.json + env: + GITHUB_TOKEN: ${{ secrets.TOKEN_BUILD }} + + - name: Cleanup build artifacts + if: always() + run: | + rm -f wgrplane-linux-amd64 wgrplane-linux-arm64 latest.json + rm -rf app/frontend/node_modules app/frontend/dist + echo "Cleanup done"