fix: use softprops/action-gh-release and add cleanup step
Release / build-and-release (push) Failing after 1m16s

This commit is contained in:
datadunia
2026-05-08 01:35:05 +07:00
parent 0c6bac4c22
commit d0d529450c
+29 -40
View File
@@ -7,34 +7,20 @@ on:
permissions: permissions:
contents: write contents: write
actions: read
jobs: jobs:
build: build-and-release:
runs-on: ubuntu-latest runs-on: ubuntu-latest
strategy:
matrix:
goarch: [amd64, arm64]
steps: steps:
- name: Clone repository with submodules - name: Clone repository with submodules
run: | run: |
# 1. Bersihkan semua config global agar tidak ada interferensi header
git config --global --remove-section http || true git config --global --remove-section http || true
git config --global --unset-all core.askPass || true git config --global --unset-all core.askPass || true
# 2. Masukkan token ke variabel
TOKEN="${{ secrets.TOKEN_BUILD }}" 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 \ git clone --recurse-submodules \
-c credential.helper="" \ -c credential.helper="" \
https://x-token-auth:$TOKEN@git.datadunia.com/devops/wireguard-vpn.git . 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 - name: Setup Go
uses: actions/setup-go@v5 uses: actions/setup-go@v5
with: with:
@@ -51,43 +37,46 @@ jobs:
npm install npm install
npm run build npm run build
- name: Build Go binary - name: Build Go binaries
env:
GOOS: linux
GOARCH: ${{ matrix.goarch }}
run: | run: |
cd app cd app
go build -o ../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: Upload binary artifact
uses: actions/upload-artifact@v3
with:
name: wgrplane-linux-${{ matrix.goarch }}
path: wgrplane-linux-${{ matrix.goarch }}
- name: Generate latest.json - name: Generate latest.json
run: | run: |
VERSION="${{ gitea.ref_name }}" 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')" 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)" 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)"
# Generate latest.json REPO="${{ gitea.repository }}"
cat > latest.json << EOF SERVER="${{ gitea.server_url }}"
cat > latest.json << ENDJSON
{ {
"version": "$VERSION", "version": "$VERSION",
"release_date": "$RELEASE_DATE", "release_date": "$RELEASE_DATE",
"changelog": $(echo "$CHANGELOG" | jq -R -s '.'), "changelog": $(echo "$CHANGELOG" | jq -R -s '.'),
"download_urls": { "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')", "amd64": "${SERVER}/${REPO}/releases/download/${VERSION}/wgrplane-linux-amd64",
"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')" "arm64": "${SERVER}/${REPO}/releases/download/${VERSION}/wgrplane-linux-arm64"
} }
} }
EOF ENDJSON
- name: Upload latest.json artifact - name: Create Release
uses: actions/upload-artifact@v3 uses: softprops/action-gh-release@v2
with: with:
name: latest.json name: ${{ gitea.ref_name }}
path: latest.json 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"