Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| a799af3d54 | |||
| 981506c96c |
@@ -1,15 +0,0 @@
|
|||||||
name: Beta Release
|
|
||||||
|
|
||||||
on:
|
|
||||||
push:
|
|
||||||
tags:
|
|
||||||
- 'v*-beta*'
|
|
||||||
- 'v*-test*'
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
deploy:
|
|
||||||
if: "contains(github.ref_name, 'beta') || contains(github.ref_name, 'test')"
|
|
||||||
uses: ./.gitea/workflows/deploy_call.yaml
|
|
||||||
with:
|
|
||||||
prerelease: true
|
|
||||||
secrets: inherit
|
|
||||||
@@ -1,136 +0,0 @@
|
|||||||
name: Deploy
|
|
||||||
|
|
||||||
on:
|
|
||||||
workflow_call:
|
|
||||||
inputs:
|
|
||||||
prerelease:
|
|
||||||
description: 'Mark as prerelease'
|
|
||||||
required: false
|
|
||||||
type: boolean
|
|
||||||
default: false
|
|
||||||
|
|
||||||
permissions:
|
|
||||||
contents: write
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
build-and-release:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
steps:
|
|
||||||
- name: Clone repository with submodules
|
|
||||||
run: |
|
|
||||||
git config --global --remove-section http || true
|
|
||||||
git config --global --unset-all core.askPass || true
|
|
||||||
TOKEN="${{ secrets.BUILD_TOKEN }}"
|
|
||||||
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
|
|
||||||
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o ../wgrplane-linux-amd64 .
|
|
||||||
CGO_ENABLED=0 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')"
|
|
||||||
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
|
|
||||||
|
|
||||||
- name: Create Release and upload assets
|
|
||||||
env:
|
|
||||||
TOKEN: ${{ secrets.BUILD_TOKEN }}
|
|
||||||
run: |
|
|
||||||
if [ -z "$TOKEN" ]; then
|
|
||||||
echo "Value: [EMPTY]"
|
|
||||||
exit 1
|
|
||||||
else
|
|
||||||
echo "Length: ${#TOKEN} characters"
|
|
||||||
fi
|
|
||||||
|
|
||||||
REPO="${{ gitea.repository }}"
|
|
||||||
TAG="${{ gitea.ref_name }}"
|
|
||||||
API="${{ gitea.server_url }}/api/v1"
|
|
||||||
|
|
||||||
# 0. Check & Delete Existing Release
|
|
||||||
echo "=== 0. Check & Delete Existing Release ==="
|
|
||||||
EXISTING_RESP=$(curl -s -H "Authorization: token $TOKEN" "$API/repos/$REPO/releases/tags/$TAG")
|
|
||||||
EXISTING_ID=$(echo "$EXISTING_RESP" | grep -o '"id":[0-9]*' | head -n 1 | cut -d':' -f2 || true)
|
|
||||||
|
|
||||||
if [ -n "$EXISTING_ID" ] && [ "$EXISTING_ID" != "null" ]; then
|
|
||||||
echo "⚠️ Found existing release for tag $TAG with ID: $EXISTING_ID. Deleting..."
|
|
||||||
DELETE_RESP=$(curl -s -w "\n%{http_code}" -X DELETE -H "Authorization: token $TOKEN" "$API/repos/$REPO/releases/$EXISTING_ID")
|
|
||||||
echo "✅ Delete response: $DELETE_RESP"
|
|
||||||
else
|
|
||||||
echo "No existing release found for $TAG. Proceeding..."
|
|
||||||
fi
|
|
||||||
|
|
||||||
# 1. Create Release
|
|
||||||
echo "=== 1. Create New Release ==="
|
|
||||||
JSON_BODY=$(printf '{"tag_name":"%s","name":"%s","body":"Release %s","draft":false,"prerelease":%s}' "$TAG" "$TAG" "$TAG" "${{ inputs.prerelease }}")
|
|
||||||
|
|
||||||
RELEASE_RESP=$(curl -s -X POST \
|
|
||||||
-H "Authorization: token $TOKEN" \
|
|
||||||
-H "Content-Type: application/json" \
|
|
||||||
-d "$JSON_BODY" \
|
|
||||||
"$API/repos/$REPO/releases")
|
|
||||||
|
|
||||||
# Ambil ID dengan lebih teliti
|
|
||||||
# Tambahkan || true agar grep tidak membuat script crash (karena set -e) jika id tidak ditemukan
|
|
||||||
RELEASE_ID=$(echo "$RELEASE_RESP" | grep -o '"id":[0-9]*' | head -n 1 | cut -d':' -f2 || true)
|
|
||||||
|
|
||||||
if [ -z "$RELEASE_ID" ] || [ "$RELEASE_ID" = "null" ]; then
|
|
||||||
echo "Gagal membuat release. Response: $RELEASE_RESP"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo "Release ID: $RELEASE_ID"
|
|
||||||
|
|
||||||
# 2. Upload Assets
|
|
||||||
for FILE in wgrplane-linux-amd64 wgrplane-linux-arm64 latest.json; do
|
|
||||||
if [ -f "$FILE" ]; then
|
|
||||||
echo "Uploading $FILE..."
|
|
||||||
curl -s -X POST \
|
|
||||||
-H "Authorization: token $TOKEN" \
|
|
||||||
-F "attachment=@$FILE" \
|
|
||||||
"$API/repos/$REPO/releases/$RELEASE_ID/assets?name=$FILE"
|
|
||||||
else
|
|
||||||
echo "Skip $FILE (tidak ditemukan)"
|
|
||||||
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"
|
|
||||||
@@ -1,14 +1,29 @@
|
|||||||
name: Release
|
name: Debug Release API
|
||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
tags:
|
branches:
|
||||||
- 'v[0-9]*.[0-9]*.[0-9]'
|
- debug-release
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
deploy:
|
debug-api:
|
||||||
if: "!contains(github.ref_name, 'beta') && !contains(github.ref_name, 'test')"
|
runs-on: ubuntu-latest
|
||||||
uses: ./.gitea/workflows/deploy_call.yaml
|
steps:
|
||||||
with:
|
- name: Debug token and API
|
||||||
prerelease: false
|
run: |
|
||||||
secrets: inherit
|
TOKEN="${{ secrets.BUILD_TOKEN }}"
|
||||||
|
REPO="${{ gitea.repository }}"
|
||||||
|
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 "=== 2. GET /user (auth test) ==="
|
||||||
|
curl -sv -H "Authorization: token $TOKEN" "$API/user" 2>&1 | head -30
|
||||||
|
|
||||||
|
echo "=== 3. GET releases list ==="
|
||||||
|
curl -s -w "\nHTTP_CODE:%{http_code}" \
|
||||||
|
-H "Authorization: token $TOKEN" \
|
||||||
|
"$API/repos/$REPO/releases"
|
||||||
|
|||||||
@@ -355,36 +355,19 @@ cd ../..
|
|||||||
# Server starts on :10087
|
# Server starts on :10087
|
||||||
```
|
```
|
||||||
|
|
||||||
### Option 4: Native CLI / Systemd Service
|
### Option 4: Systemd Service
|
||||||
|
|
||||||
The WGRplane binary includes a built-in CLI to manage its own systemd service.
|
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
# Check system dependencies first
|
# Install service file
|
||||||
./wgrplane doctor
|
sudo cp wgrplane.service /etc/systemd/system/
|
||||||
|
sudo systemctl daemon-reload
|
||||||
# Install as systemd service (auto-creates unit, enables, and starts)
|
sudo systemctl enable wgrplane.service
|
||||||
sudo ./wgrplane install
|
sudo systemctl start wgrplane.service
|
||||||
|
|
||||||
# View logs
|
# View logs
|
||||||
journalctl -u wgrplane -f
|
journalctl -u wgrplane.service -f
|
||||||
|
|
||||||
# Other available commands:
|
|
||||||
sudo ./wgrplane stop
|
|
||||||
sudo ./wgrplane restart
|
|
||||||
sudo ./wgrplane uninstall
|
|
||||||
```
|
```
|
||||||
|
|
||||||
### Manual Serve & Config
|
|
||||||
|
|
||||||
To run the server manually in the foreground with custom ports:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
./wgrplane serve --port 8080 --host 127.0.0.1
|
|
||||||
```
|
|
||||||
|
|
||||||
On first run, it generates a default configuration file at `~/.config/wgrplane/config.json`.
|
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
## 📁 Project Structure
|
## 📁 Project Structure
|
||||||
|
|||||||
+1
-1
Submodule app updated: b43866d42c...57ffe45ab7
Reference in New Issue
Block a user