82 lines
2.5 KiB
YAML
82 lines
2.5 KiB
YAML
name: Release
|
|
|
|
on:
|
|
push:
|
|
tags:
|
|
- 'v*'
|
|
|
|
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.TOKEN_BUILD }}"
|
|
git clone --recurse-submodules \
|
|
-c credential.helper="" \
|
|
https://x-token-auth:$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')"
|
|
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": "${SERVER}/${REPO}/releases/download/${VERSION}/wgrplane-linux-amd64",
|
|
"arm64": "${SERVER}/${REPO}/releases/download/${VERSION}/wgrplane-linux-arm64"
|
|
}
|
|
}
|
|
ENDJSON
|
|
|
|
- name: Create Release
|
|
uses: actions/gitea-release-action@v1
|
|
with:
|
|
files: |-
|
|
wgrplane-linux-amd64
|
|
wgrplane-linux-arm64
|
|
latest.json
|
|
token: ${{ secrets.TOKEN_BUILD }}
|
|
|
|
- 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"
|