1+ name : Build Binary
2+
3+ on :
4+ push :
5+ branches : [ "main" ]
6+ pull_request :
7+ branches : [ "main" ]
8+
9+ jobs :
10+ build-ui :
11+ runs-on : ubuntu-latest
12+ steps :
13+ - uses : actions/checkout@v4
14+
15+ # Setup Node.js for UI build
16+ - name : Setup Node.js
17+ uses : actions/setup-node@v4
18+ with :
19+ node-version : ' 20'
20+ cache : ' npm'
21+ cache-dependency-path : ui/html/package.json
22+
23+ # Build the UI
24+ - name : Build UI
25+ run : |
26+ cd ui/html
27+ npm ci
28+ npm run build
29+
30+ # Upload the built UI as an artifact for other jobs
31+ - name : Upload UI Build
32+ uses : actions/upload-artifact@v4
33+ with :
34+ name : ui-build
35+ path : ui/html/dist
36+ retention-days : 1
37+
38+ build-binary :
39+ needs : build-ui
40+ runs-on : ubuntu-latest
41+ strategy :
42+ matrix :
43+ goos : [linux, darwin, windows]
44+ goarch : [amd64, arm64]
45+ steps :
46+ - uses : actions/checkout@v4
47+
48+ # Download UI build artifacts
49+ - name : Download UI Build
50+ uses : actions/download-artifact@v4
51+ with :
52+ name : ui-build
53+ path : ui/html/dist
54+
55+ # Setup Go for building the application
56+ - name : Setup Go
57+ uses : actions/setup-go@v5
58+ with :
59+ go-version : ' 1.24'
60+ cache : true
61+
62+ # Install dependencies
63+ - name : Install dependencies
64+ run : |
65+ sudo apt-get update
66+ sudo apt-get install -y build-essential
67+
68+
69+ # Build the Go application with proper naming
70+ - name : Build Go Application
71+ env :
72+ GOOS : ${{ matrix.goos }}
73+ GOARCH : ${{ matrix.goarch }}
74+ run : |
75+ BINARY_NAME="NetGATE"
76+ if [ "${{ matrix.goos }}" = "windows" ]; then
77+ BINARY_NAME="${BINARY_NAME}.exe"
78+ fi
79+ OUTPUT_NAME="${BINARY_NAME}-${{ matrix.goos }}-${{ matrix.goarch }}"
80+ if [ "${{ matrix.goos }}" = "windows" ]; then
81+ go build -v -o "${OUTPUT_NAME}"
82+ else
83+ go build -v -o "${OUTPUT_NAME}"
84+ fi
85+
86+ # Upload the built binary as an artifact
87+ - name : Upload Binary
88+ uses : actions/upload-artifact@v4
89+ with :
90+ name : NetGATE-${{ matrix.goos }}-${{ matrix.goarch }}
91+ path : NetGATE-${{ matrix.goos }}-${{ matrix.goarch }}${{ matrix.goos == 'windows' && '.exe' || '' }}
0 commit comments