-
Notifications
You must be signed in to change notification settings - Fork 2
342 lines (300 loc) · 11.3 KB
/
build-master.yml
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
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
name: Build master binaries
on:
push:
branches: [ master ]
jobs:
build-linux:
name: Build (Linux)
runs-on: ubuntu-latest
container:
image: ubuntu:18.04
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: 1.21
- name: Install dependencies
run: |
cat << EOF > /etc/apt/sources.list
deb [arch=amd64,i386] http://archive.ubuntu.com/ubuntu/ bionic main universe
deb [arch=armhf,arm64] http://ports.ubuntu.com/ubuntu-ports/ bionic main universe
deb [arch=amd64,i386] http://archive.ubuntu.com/ubuntu/ bionic-updates main universe
deb [arch=armhf,arm64] http://ports.ubuntu.com/ubuntu-ports/ bionic-updates main universe
deb [arch=amd64,i386] http://security.ubuntu.com/ubuntu/ bionic-security main universe
deb [arch=armhf,arm64] http://ports.ubuntu.com/ubuntu-ports/ bionic-security main universe
EOF
dpkg --add-architecture i386
dpkg --add-architecture armhf
dpkg --add-architecture arm64
apt update
apt install --no-install-recommends -y \
ca-certificates zip \
build-essential \
gcc-7-multilib g++-7-multilib \
gcc-arm-linux-gnueabihf g++-arm-linux-gnueabihf \
gcc-aarch64-linux-gnu g++-aarch64-linux-gnu
- name: Build CLI
env:
CGO_ENABLED: 0
run: |
GOARCH=amd64 go build -o ./build/x86-64/dsl ./cmd
GOARCH=386 go build -o ./build/x86/dsl ./cmd
GOARCH=arm GOARM=6 go build -o ./build/arm/dsl ./cmd
GOARCH=arm64 go build -o ./build/arm64/dsl ./cmd
- name: Build GUI (x86-64)
env:
CGO_ENABLED: 1
GOARCH: amd64
run: |
apt install --no-install-recommends -y libgtk-3-dev libwebkit2gtk-4.0-dev
go build -tags gui -o ./build/x86-64/dsl-gui ./cmd
apt remove -y libgtk-3-dev libwebkit2gtk-4.0-dev
- name: Build GUI (x86)
env:
PKG_CONFIG_PATH: /usr/lib/i386-linux-gnu/pkgconfig
CGO_ENABLED: 1
GOARCH: 386
run: |
apt install --no-install-recommends -y libgtk-3-dev:i386 libwebkit2gtk-4.0-dev:i386
go build -tags gui -o ./build/x86/dsl-gui ./cmd
apt remove -y libgtk-3-dev:i386 libwebkit2gtk-4.0-dev:i386
- name: Build GUI (arm)
env:
CC: arm-linux-gnueabihf-gcc
CXX: arm-linux-gnueabihf-g++
PKG_CONFIG_PATH: /usr/lib/arm-linux-gnueabihf/pkgconfig
CGO_ENABLED: 1
GOARCH: arm
GOARM: 6
run: |
apt install --no-install-recommends -y libgtk-3-dev:armhf libwebkit2gtk-4.0-dev:armhf
go build -tags gui -o ./build/arm/dsl-gui ./cmd
apt remove -y libgtk-3-dev:armhf libwebkit2gtk-4.0-dev:armhf
- name: Build GUI (arm64)
env:
CC: aarch64-linux-gnu-gcc
CXX: aarch64-linux-gnu-g++
PKG_CONFIG_PATH: /usr/lib/aarch64-linux-gnu/pkgconfig
CGO_ENABLED: 1
GOARCH: arm64
run: |
apt install --no-install-recommends -y libgtk-3-dev:arm64 libwebkit2gtk-4.0-dev:arm64
go build -tags gui -o ./build/arm64/dsl-gui ./cmd
apt remove -y libgtk-3-dev:arm64 libwebkit2gtk-4.0-dev:arm64
- name: Zip
run: |
for folder in "$PWD"/build/*/; do
name="$(basename "$folder")"
cd "$folder"
zip -r "../$name.zip" ./*
done
- name: Upload artifact
uses: actions/upload-artifact@v3
with:
name: linux
path: ./build/*.zip
build-windows:
name: Build (Windows)
runs-on: windows-2022
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: 1.21
- name: Download toolchain
run: |
$ToolchainVersion = "20231128"
$ToolchainSHA256 = "7a344dafa6942de2c1f4643b3eb5c5ce5317fbab671a887e4d39f326b331798f"
New-Item -ItemType Directory .\toolchain
$ProgressPreference = "SilentlyContinue"
Invoke-WebRequest "https://github.com/mstorsjo/llvm-mingw/releases/download/$ToolchainVersion/llvm-mingw-$ToolchainVersion-ucrt-x86_64.zip" -OutFile .\toolchain\llvm-mingw.zip
$actualSHA256 = Get-FileHash -Algorithm SHA256 .\toolchain\llvm-mingw.zip
if ($actualSHA256.Hash -ne $ToolchainSHA256) {
Write-Output "Toolchain checksum does not match!"
exit 1
}
Expand-Archive .\toolchain\llvm-mingw.zip .\toolchain
Move-Item ".\toolchain\llvm-mingw-$ToolchainVersion-ucrt-x86_64" .\toolchain\llvm-mingw
- name: Build CLI (x86-64)
env:
CGO_ENABLED: 0
GOARCH: amd64
run: |
go build -o .\build\x86-64\dsl.exe .\cmd
- name: Build CLI (x86)
env:
CGO_ENABLED: 0
GOARCH: 386
run: |
go build -o .\build\x86\dsl.exe .\cmd
- name: Build CLI (arm64)
env:
CGO_ENABLED: 0
GOARCH: arm64
run: |
go build -o .\build\arm64\dsl.exe .\cmd
- name: Build GUI (x86-64)
env:
CC: x86_64-w64-mingw32-clang
CXX: x86_64-w64-mingw32-clang++
CGO_ENABLED: 1
GOARCH: amd64
run: |
$Env:Path = "$PWD\toolchain\llvm-mingw\bin;$Env:Path"
go build -tags gui -ldflags="-H windowsgui" -o .\build\x86-64\dsl-gui.exe .\cmd
- name: Build GUI (x86)
env:
CC: i686-w64-mingw32-clang
CXX: i686-w64-mingw32-clang++
CGO_ENABLED: 1
GOARCH: 386
run: |
$Env:Path = "$PWD\toolchain\llvm-mingw\bin;$Env:Path"
go build -tags gui -ldflags="-H windowsgui" -o .\build\x86\dsl-gui.exe .\cmd
- name: Build GUI (arm64)
env:
CC: aarch64-w64-mingw32-clang
CXX: aarch64-w64-mingw32-clang++
CGO_ENABLED: 1
GOARCH: arm64
run: |
$Env:Path = "$PWD\toolchain\llvm-mingw\bin;$Env:Path"
go build -tags gui -ldflags="-H windowsgui" -o .\build\arm64\dsl-gui.exe .\cmd
- name: Zip
run: |
foreach ($folder in $(Get-ChildItem -Directory .\build)) {
Set-Location $folder.FullName
Compress-Archive .\* "..\$($folder.Name).zip"
}
- name: Upload artifact
uses: actions/upload-artifact@v3
with:
name: windows
path: ./build/*.zip
build-macos:
name: Build (macOS)
runs-on: macos-11
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: 1.21
- name: Build CLI
env:
CGO_ENABLED: 0
run: |
GOARCH=amd64 go build -o ./build/universal/dsl-x86-64 ./cmd
GOARCH=arm64 go build -o ./build/universal/dsl-arm64 ./cmd
lipo -create -output ./build/universal/dsl ./build/universal/dsl-x86-64 ./build/universal/dsl-arm64
rm ./build/universal/dsl-x86-64 ./build/universal/dsl-arm64
- name: Build GUI
env:
CGO_ENABLED: 1
run: |
mkdir -p ./build/universal/dsl-gui.app/Contents/MacOS
echo << EOF > ./build/universal/dsl-gui.app/Contents/Info.plist
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleExecutable</key>
<string>dsl-gui</string>
<key>CFBundleIdentifier</key>
<string>eu.3e8.go.dsl</string>
</dict>
</plist>
EOF
sudo xcode-select -s /Applications/Xcode_11.7.app
GOARCH=amd64 SDKROOT="$(xcrun --sdk macosx10.15 --show-sdk-path)" \
go build -tags gui -o ./build/universal/dsl-gui-x86-64 ./cmd
sudo xcode-select -s /Applications/Xcode_12.4.app
GOARCH=arm64 SDKROOT="$(xcrun --sdk macosx11.1 --show-sdk-path)" \
go build -tags gui -o ./build/universal/dsl-gui-arm64 ./cmd
lipo -create -output ./build/universal/dsl-gui.app/Contents/MacOS/dsl-gui \
./build/universal/dsl-gui-x86-64 ./build/universal/dsl-gui-arm64
rm ./build/universal/dsl-gui-x86-64 ./build/universal/dsl-gui-arm64
- name: Zip
run: |
for folder in "$PWD"/build/*/; do
name="$(basename "$folder")"
cd "$folder"
zip -r "../$name.zip" ./*
done
- name: Upload artifact
uses: actions/upload-artifact@v3
with:
name: macos
path: ./build/*.zip
release:
name: Package and release
runs-on: ubuntu-latest
needs:
- build-linux
- build-windows
- build-macos
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Determine variables
id: vars
shell: bash
env:
TZ: UTC0
run: |
echo "version=$(git log -1 --format='%cd+%h' --date='format-local:%Y-%m-%d')" >> $GITHUB_OUTPUT
echo "time=$(git log -1 --format='%cd' --date='format-local:%Y-%m-%d %H:%M:%S UTC')" >> $GITHUB_OUTPUT
- name: Prepare common files
run: |
mkdir -p ./build/template
echo "${{ steps.vars.outputs.version }}" > ./build/template/VERSION
cp LICENSE ./build/template/
cp ./cmd/LICENSE-3RD-PARTY ./build/template/
cp README.md ./build/template/
mkdir ./build/template/docs
cp ./docs/*.md ./build/template/docs/
- name: Install pandoc
run: |
sudo apt update
sudo apt install -y pandoc
- name: Build HTML documentation
run: |
./docs/build.sh ./build/template
- name: Download artifacts
uses: actions/download-artifact@v3
with:
path: ./artifacts
- name: Build archives
shell: bash
run: |
cd ./build
for artifact in ../artifacts/*/*.zip; do
target="$(basename "$(dirname "$artifact")")"
arch="$(basename -s ".zip" "$artifact")"
name="dsl_${{ steps.vars.outputs.version }}_${target}_${arch}"
cp -r ./template "./$name"
unzip "../artifacts/$target/$arch.zip" -d "./$name/"
zip -r "$name.zip" "$name"
done
- name: Create release
uses: ncipollo/release-action@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
tag: github-master-builds
prerelease: true
allowUpdates: true
removeArtifacts: true
artifacts: "./build/*.zip"
artifactContentType: application/zip
name: Auto-built binaries
body: |
These binaries are automatically built from the master branch.\
Current version: ${{ github.sha }} (${{ steps.vars.outputs.time }})
Select the build for your platform from the assets below.
*Note: If you want to get the corresponding source code please use Git.\
The source archives linked below don't contain the actual source.*