-
Notifications
You must be signed in to change notification settings - Fork 0
134 lines (109 loc) · 3.13 KB
/
build-backend.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
name: Build backend
on:
workflow_dispatch:
pull_request:
paths:
- backend/**
jobs:
build-backend-linux:
name: "Build backend for linux"
runs-on: ubuntu-latest
# Runs on alpine because it is easier to statically link the library
container:
image: golang:alpine
env:
BACKEND_DIR: ./backend
steps:
- name: "Install packages"
run: apk update && apk add --no-cache libpcap-dev musl-dev gcc go
- uses: actions/checkout@v4
with:
sparse-checkout: backend
- name: "Create output path"
working-directory: "${{env.BACKEND_DIR}}"
run: mkdir ./output
- name: "Build (64 bit)"
working-directory: "${{env.BACKEND_DIR}}/cmd"
env:
CGO_ENABLED: 1
GOARCH: amd64
GOOS: linux
run: |
go build -ldflags '-linkmode external -extldflags "-static"' -o ../output/backend-linux-64
- name: "Upload build"
uses: actions/upload-artifact@v4
with:
name: backend-linux
path: "${{env.BACKEND_DIR}}/output/*"
retention-days: 3
compression-level: 9
build-backend-windows:
name: "Build backend for windows"
runs-on: windows-latest
env:
BACKEND_DIR: ".\\backend"
steps:
- uses: actions/checkout@v3
- name: "Setup Go"
uses: actions/setup-go@v4
with:
go-version: "1.21.3"
cache-dependency-path: "${{env.BACKEND_DIR}}\\go.sum"
- name: "Create output path"
working-directory: "${{env.BACKEND_DIR}}"
run: mkdir .\output
- name: "Build (64 bit)"
working-directory: "${{env.BACKEND_DIR}}\\cmd"
env:
CGO_ENABLED: 1
GOARCH: amd64
GOOS: windows
run: |
go build -o ..\output\backend-windows-64.exe
- name: "Upload build"
uses: actions/upload-artifact@v4
with:
name: backend-windows
path: "${{env.BACKEND_DIR}}\\output\\*"
retention-days: 3
compression-level: 9
build-backend-mac:
name: "Build backend for macOS"
runs-on: macos-latest
env:
BACKEND_DIR: ./backend
steps:
- name: "Install packages"
run: brew install libpcap
- name: "Setup Go"
uses: actions/setup-go@v4
with:
go-version: "1.21.3"
cache-dependency-path: "${{env.BACKEND_DIR}}/go.sum"
- uses: actions/checkout@v3
- name: "Create output path"
working-directory: "${{env.BACKEND_DIR}}"
run: mkdir ./output
- name: "Build (64 bit)"
working-directory: "${{env.BACKEND_DIR}}/cmd"
env:
CGO_ENABLED: 1
GOARCH: amd64
GOOS: darwin
run: |
go build -o ../output/backend-macos-64
- name: "Build (apple 64 bit)"
working-directory: "${{env.BACKEND_DIR}}/cmd"
env:
CGO_ENABLED: 1
GOARCH: arm64
GOOS: darwin
run: |
go build -o ../output/backend-macos-m1-64
- name: "Upload build"
uses: actions/upload-artifact@v4
with:
name: backend-macos
path: "${{env.BACKEND_DIR}}/output/*"
retention-days: 3
compression-level: 9