98 lines
3.8 KiB
YAML
98 lines
3.8 KiB
YAML
name: Release
|
|
|
|
on:
|
|
push:
|
|
tags:
|
|
- 'v*'
|
|
|
|
permissions:
|
|
contents: write
|
|
actions: read
|
|
|
|
jobs:
|
|
build:
|
|
runs-on: ubuntu-latest
|
|
strategy:
|
|
matrix:
|
|
goarch: [amd64, arm64]
|
|
steps:
|
|
- name: Clone repository with submodules
|
|
run: |
|
|
git clone --recurse-submodules -c "url.https://token:${{ gitea.token }}@git.datadunia.com/.insteadOf=https://git.datadunia.com/" https://git.datadunia.com/devops/wireguard-vpn.git
|
|
git config --global http."https://git.datadunia.com/".extraheader "Authorization: token ${{ gitea.token }}"
|
|
git config --global core.askPass ""
|
|
git clone --recurse-submodules https://git.datadunia.com/devops/wireguard-vpn.git .
|
|
|
|
# Debug
|
|
ls -la app/frontend
|
|
|
|
- name: Setup Go
|
|
uses: actions/setup-go@40f1582b2485089dde7abd97c1529aa768e1baff
|
|
with:
|
|
go-version: '1.22'
|
|
|
|
- name: Setup Node.js
|
|
uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020
|
|
with:
|
|
node-version: '20'
|
|
|
|
- name: Build Vue frontend
|
|
run: |
|
|
cd app/frontend
|
|
npm install
|
|
npm run build
|
|
|
|
- name: Build Go binary
|
|
env:
|
|
GOOS: linux
|
|
GOARCH: ${{ matrix.goarch }}
|
|
run: |
|
|
cd app
|
|
go build -o ../wgrplane-linux-${{ matrix.goarch }} .
|
|
|
|
- name: Upload binary artifact
|
|
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02
|
|
with:
|
|
name: wgrplane-linux-${{ matrix.goarch }}
|
|
path: wgrplane-linux-${{ matrix.goarch }}
|
|
|
|
- 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
|
|
{
|
|
"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')"
|
|
}
|
|
}
|
|
EOF
|
|
|
|
- name: Upload latest.json artifact
|
|
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02
|
|
with:
|
|
name: latest.json
|
|
path: latest.json
|
|
|
|
generate-latest-json:
|
|
needs: build
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Cleanup Git Config
|
|
if: always() # Pastikan tetap jalan meski job gagal
|
|
run: |
|
|
# git config --global --unset-all url."https://token:${{ gitea.token }}@${{ gitea.server_url | replace("https://", "") }}/".insteadOf
|
|
# Hapus header dan config agar tidak tersimpan di ~/.gitconfig host
|
|
git config --global --unset http.extraheader
|
|
git config --global --unset core.askPass
|
|
git config --global --unset-all http."https://git.datadunia.com/".extraheader
|
|
git config --global --unset core.askPass |