-
Notifications
You must be signed in to change notification settings - Fork 157
322 lines (256 loc) · 9.62 KB
/
build.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
# https://docs.github.com/en/free-pro-team@latest/actions/reference/workflow-syntax-for-github-actions
name: Build
on:
push:
pull_request:
workflow_dispatch:
# https://github.blog/changelog/2020-07-06-github-actions-manual-triggers-with-workflow_dispatch/
defaults:
run:
shell: bash
jobs:
###########################################################
build:
###########################################################
runs-on: ${{ matrix.runner }}
strategy:
fail-fast: false
matrix:
target: [linux, darwin, windows]
architecture: [32, 64, arm64]
build_system: [make, cmake, vs2019]
include:
- target: linux
runner: ubuntu-20.04
haxe_nightly_dir: linux64
archive_ext: tar.gz
- target: darwin
haxe_nightly_dir: mac
archive_ext: tar.gz
- target: darwin
architecture: 64
runner: macos-12
- target: darwin
architecture: arm64
runner: macos-14
- build_system: cmake
cmake_configuration: RelWithDebInfo
- build_system: vs2019
msbuild_configuration: Release
- target: windows
runner: windows-2019 # has VS2019 preinstalled which supports PlatformToolset <= v142, WindowsTargetPlatformVersion 10
haxe_nightly_dir: windows64
archive_ext: zip
- target: windows
build_system: cmake
cmake_generator: Visual Studio 16 2019
- target: windows
architecture: 32
ffmpeg_url: https://github.com/HaxeFoundation/hashlink/files/5648055/ffmpeg-3.4.2-win32-dev.zip
architecture_string: Win32
- target: windows
architecture: 64
ffmpeg_url: https://github.com/HaxeFoundation/hashlink/files/5648056/ffmpeg-3.4.2-win64-dev.zip
architecture_string: x64
exclude:
- target: linux
build_system: vs2019
- target: darwin
build_system: vs2019
- target: linux
architecture: 32
- target: darwin
architecture: 32
- target: linux
architecture: arm64
- target: windows
architecture: arm64
- target: windows
build_system: make
- target: windows
architecture: 32
build_system: cmake
steps:
- name: "SCM Checkout"
uses: actions/checkout@v4
- name: "Add msbuild to PATH"
if: matrix.build_system == 'vs2019'
uses: microsoft/setup-msbuild@v2
with:
vs-version: '[16.0,17.0)'
- name: "Mac homebrew workaround" # see https://github.com/actions/setup-python/issues/577
if: matrix.target == 'darwin'
run: |
rm /usr/local/bin/2to3
rm /usr/local/bin/idle3
rm /usr/local/bin/pydoc3
rm /usr/local/bin/python3
rm /usr/local/bin/python3-config
- name: "Install: Required Dev Packages"
run: |
set -eux
case "${{ matrix.target }}${{ matrix.architecture }}" in
linux64)
echo "MARCH=64" >> $GITHUB_ENV
sudo apt-get update -y
sudo apt-get install --no-install-recommends -y \
libmbedtls-dev \
libopenal-dev \
libpng-dev \
libsdl2-dev \
libturbojpeg-dev \
libuv1-dev \
libvorbis-dev \
libsqlite3-dev
;;
darwin*)
brew update
brew bundle
;;
windows*)
curl -fsSL --retry 3 --retry-delay 5 -o /tmp/sdl.zip https://www.libsdl.org/release/SDL2-devel-2.30.2-VC.zip
curl -fsSL --retry 3 --retry-delay 5 -o /tmp/openal.zip https://github.com/kcat/openal-soft/releases/download/1.23.1/openal-soft-1.23.1-bin.zip
curl -fsSL --retry 3 --retry-delay 5 -o /tmp/ffmpeg.zip ${{ matrix.ffmpeg_url }}
7z x /tmp/sdl.zip -oinclude; mv include/SDL2* include/sdl
7z x /tmp/openal.zip -oinclude; mv include/openal* include/openal
7z x /tmp/ffmpeg.zip -oinclude; mv include/ffmpeg* include/ffmpeg
;;
esac
- name: Install haxe
uses: krdlab/setup-haxe@f0a0baa8ccdb1fe4fc316c8f30eb3ca77aa4ea4e
with:
haxe-version: latest
- name: "Configure: Haxelib"
run: |
set -eux
haxelib setup ~/haxelib
haxelib install hashlink
haxelib list
- name: "Build: HashLink"
run: |
set -eux
case "${{ matrix.build_system }}" in
cmake)
case "${{ matrix.target }}${{ matrix.architecture }}" in
windows*)
cmake . -DCMAKE_BUILD_TYPE=${{ matrix.cmake_configuration }} \
-G "${{ matrix.cmake_generator }}" \
-A ${{ matrix.architecture_string }}
;;
*)
cmake . -DCMAKE_BUILD_TYPE=${{ matrix.cmake_configuration }} ;;
esac
cmake --build . --config ${{ matrix.cmake_configuration }}
BUILD_FOLDER=bin
;;
vs2019)
MSBuild.exe hl.sln //nologo //m //clp:ErrorsOnly \
//p:Configuration=${{ matrix.msbuild_configuration }} \
//p:Platform=${{ matrix.architecture_string }}
case "${{ matrix.architecture }}" in
64) BUILD_FOLDER=x64/${{ matrix.msbuild_configuration }} ;;
32) BUILD_FOLDER=${{ matrix.msbuild_configuration }} ;;
esac
echo "WINDOWS_BUILD_FOLDER=$BUILD_FOLDER" >> $GITHUB_ENV
;;
make)
make
sudo make install
if [[ ${{ matrix.target }} == linux ]]; then
sudo ldconfig
fi
BUILD_FOLDER=.
;;
esac
ls -l $BUILD_FOLDER
- name: "Test"
run: |
set -eux
case "${{ matrix.build_system }}" in
cmake)
ctest --verbose --build-config ${{ matrix.cmake_configuration }}
;;
vs2019)
${{ env.WINDOWS_BUILD_FOLDER }}/hl.exe --version
;;
make)
if [[ ${{ matrix.architecture }} != arm64 ]]; then
./hl --version
case ${{ matrix.target }} in
linux) ldd -v ./hl ;;
darwin) otool -L ./hl ;;
esac
haxe -hl hello.hl -cp other/tests -main HelloWorld -D interp
./hl hello.hl
# ensure the executable still works when installed globally
cp hello.hl /tmp
pushd /tmp
hl hello.hl
popd
fi
haxe -hl src/_main.c -cp other/tests -main HelloWorld
make hlc
./hlc
;;
esac
- name: "Package"
run: |
set -eux
case "${{ matrix.target }}${{matrix.architecture}}" in
darwinarm64) platform_name=darwin-arm64 ;;
darwin64) platform_name=darwin ;;
windows*) platform_name=win${{matrix.architecture}} ;;
linux64) platform_name=linux-amd64 ;;
esac
short_commit=$(git rev-parse --short HEAD)
case "${{ matrix.build_system }}" in
cmake)
dist_folder=hashlink-${short_commit}-${platform_name}-cmake
cpack -D CPACK_PACKAGE_FILE_NAME=$dist_folder -C ${{ matrix.cmake_configuration }}
echo "HASHLINK_DISTRIBUTION=bin/$dist_folder.${{ matrix.archive_ext }}" >> $GITHUB_ENV
;;
*)
dist_folder=hashlink-${short_commit}-${platform_name}
make PACKAGE_NAME=$dist_folder MARCH=${{ matrix.architecture }} release
echo "HASHLINK_DISTRIBUTION=$dist_folder.${{ matrix.archive_ext }}" >> $GITHUB_ENV
;;
esac
- name: "Share: build artifact"
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.target }}-${{ matrix.build_system }}-${{ matrix.architecture }}
path: ${{ env.HASHLINK_DISTRIBUTION }}
###########################################################
publish-latest-release:
###########################################################
runs-on: ubuntu-latest
needs:
- build
if: github.ref == 'refs/heads/master'
concurrency: publish-latest-release # https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions#jobsjob_idconcurrency
steps:
- name: "SCM Checkout"
uses: actions/checkout@v4
- name: "Get: all build artifacts"
uses: actions/download-artifact@v4
- name: "Delete previous 'latest' release"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
set -eu
gh release delete latest --cleanup-tag --yes || true
- name: "Create 'latest' Release"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
set -eux
# https://hub.github.com/hub-release.1.html
short_commit=$(git rev-parse --short HEAD)
gh release create latest \
--prerelease \
--title "HashLink Nightly Build" \
"darwin-make-64/hashlink-${short_commit}-darwin.tar.gz#hashlink-latest-darwin.tar.gz" \
"darwin-make-arm64/hashlink-${short_commit}-darwin-arm64.tar.gz#hashlink-latest-darwin-arm64.tar.gz" \
"linux-make-64/hashlink-${short_commit}-linux-amd64.tar.gz#hashlink-latest-linux-amd64.tar.gz" \
"windows-vs2019-32/hashlink-${short_commit}-win32.zip#hashlink-latest-win32.zip" \
"windows-vs2019-64/hashlink-${short_commit}-win64.zip#hashlink-latest-win64.zip"