-
Notifications
You must be signed in to change notification settings - Fork 33
382 lines (333 loc) · 14 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
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
name: Build
on:
workflow_dispatch:
push:
branches: master
pull_request:
branches: master
release:
types: [created]
jobs:
vs2022-installer:
name: Build VS 2022 (Installer), ${{ matrix.build_type }}, ${{ matrix.arch }}
runs-on: windows-2022
strategy:
matrix:
build_type: [RelWithDebInfo]
arch: [Win32]
steps:
- uses: actions/checkout@v3
with:
submodules: true
fetch-depth: 0
- name: Add msbuild to PATH
uses: microsoft/[email protected]
- name: Create Build Environment
run: cmake -E make_directory ${{github.workspace}}/build/actions
- name: Configure CMake
shell: bash
working-directory: ${{github.workspace}}/build/actions
run: cmake $GITHUB_WORKSPACE -A ${{ matrix.arch }} -DBuildPortableVersion=OFF
- name: Build
working-directory: ${{github.workspace}}/build/actions
shell: cmd
run: msbuild /m /p:Configuration=${{ matrix.build_type }} PACKAGE.vcxproj
#- uses: 'actions/upload-artifact@v3'
# with:
# name: Windows Binaries (Installer), ${{ matrix.build_type }}, ${{ matrix.arch }}
# path: ${{github.workspace}}/build/actions/out/${{ matrix.build_type }}/*
- uses: 'actions/upload-artifact@v3'
with:
name: Windows Package (Installer), ${{ matrix.build_type }}, ${{ matrix.arch }}
path: ${{github.workspace}}/build/actions/out/*.exe
# As actions/upload-release-asset seems to demand exact filenames and content types we use a script instead
- name: Upload Release
if: ${{ github.event_name == 'release' && matrix.build_type == 'RelWithDebInfo' }}
uses: actions/github-script@v6
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const fs = require('fs').promises;
for ( let filename of await fs.readdir(String.raw`${{github.workspace}}/build/actions/out/`) )
{
if ( filename.endsWith('.exe') )
{
await github.rest.repos.uploadReleaseAsset(
{
owner: context.repo.owner,
repo: context.repo.repo,
release_id: ${{ github.event.release.id }},
name: filename,
data: await fs.readFile( String.raw`${{github.workspace}}/build/actions/out/` + filename )
}
);
}
}
vs2022:
name: Build VS 2022 (Portable), ${{ matrix.build_type }}, ${{ matrix.arch }}
runs-on: windows-2022
strategy:
matrix:
build_type: [Debug, RelWithDebInfo]
arch: [Win32, x64]
steps:
- uses: actions/checkout@v3
with:
submodules: true
fetch-depth: 0
- name: Add msbuild to PATH
uses: microsoft/[email protected]
- name: Create Build Environment
run: cmake -E make_directory ${{github.workspace}}/build/actions
- name: Configure CMake
shell: bash
working-directory: ${{github.workspace}}/build/actions
run: cmake $GITHUB_WORKSPACE -A ${{ matrix.arch }} -DBuildPortableVersion=ON
- name: Build
working-directory: ${{github.workspace}}/build/actions
shell: cmd
run: msbuild /m /p:Configuration=${{ matrix.build_type }} PACKAGE.vcxproj
#- uses: 'actions/upload-artifact@v3'
# with:
# name: Windows Binaries (Portable), ${{ matrix.build_type }}, ${{ matrix.arch }}
# path: ${{github.workspace}}/build/actions/out/${{ matrix.build_type }}/*
- uses: 'actions/upload-artifact@v3'
if: ${{ matrix.build_type == 'RelWithDebInfo' }}
with:
name: Windows Package (Portable), ${{ matrix.build_type }}, ${{ matrix.arch }}
path: ${{github.workspace}}/build/actions/out/*.zip
# As actions/upload-release-asset seems to demand exact filenames and content types we use a script instead
- name: Upload Release
if: ${{ github.event_name == 'release' && matrix.build_type == 'RelWithDebInfo' }}
uses: actions/github-script@v6
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const fs = require('fs').promises;
for ( let filename of await fs.readdir(String.raw`${{github.workspace}}/build/actions/out/`) )
{
if ( filename.endsWith('.zip') )
{
await github.rest.repos.uploadReleaseAsset(
{
owner: context.repo.owner,
repo: context.repo.repo,
release_id: ${{ github.event.release.id }},
name: filename,
data: await fs.readFile( String.raw`${{github.workspace}}/build/actions/out/` + filename )
}
);
}
}
vs2019_xp:
name: Build VS 2019 (Portable - WinXP), ${{ matrix.build_type }}, ${{ matrix.arch }}
runs-on: windows-2019
strategy:
matrix:
build_type: [Debug, RelWithDebInfo]
arch: [Win32]
steps:
- uses: actions/checkout@v3
with:
submodules: true
fetch-depth: 0
- name: Install WinXP Toolset
shell: powershell
run: |
Set-Location "C:\Program Files (x86)\Microsoft Visual Studio\Installer\"
Start-Process -FilePath vs_installer.exe -ArgumentList "modify", "--installPath", "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise", "--add Microsoft.VisualStudio.Component.WinXP", "--quiet", "--norestart", "--nocache" -Wait -PassThru -WindowStyle Hidden
- name: Add msbuild to PATH
uses: microsoft/[email protected]
- name: Create Build Environment
run: cmake -E make_directory ${{github.workspace}}/build/actions
- name: Configure CMake
shell: bash
working-directory: ${{github.workspace}}/build/actions
run: cmake $GITHUB_WORKSPACE -A ${{ matrix.arch }} -T v141_xp -DBuildPortableVersion=ON
- name: Build
working-directory: ${{github.workspace}}/build/actions
shell: cmd
run: msbuild /m /p:Configuration=${{ matrix.build_type }} PACKAGE.vcxproj
#- uses: 'actions/upload-artifact@v3'
# with:
# name: Windows Binaries (Portable - WinXP), ${{ matrix.build_type }}, ${{ matrix.arch }}
# path: ${{github.workspace}}/build/actions/out/${{ matrix.build_type }}/*
- uses: 'actions/upload-artifact@v3'
if: ${{ matrix.build_type == 'RelWithDebInfo' }}
with:
name: Windows Package (Portable - WinXP), ${{ matrix.build_type }}, ${{ matrix.arch }}
path: ${{github.workspace}}/build/actions/out/*.zip
# As actions/upload-release-asset seems to demand exact filenames and content types we use a script instead
- name: Upload Release
if: ${{ github.event_name == 'release' && matrix.build_type == 'RelWithDebInfo' }}
uses: actions/github-script@v6
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const fs = require('fs').promises;
for ( let filename of await fs.readdir(String.raw`${{github.workspace}}/build/actions/out/`) )
{
if ( filename.endsWith('.zip') )
{
await github.rest.repos.uploadReleaseAsset(
{
owner: context.repo.owner,
repo: context.repo.repo,
release_id: ${{ github.event.release.id }},
name: filename.split('.').slice(0, -1).join('.') + "-winxp.zip",
data: await fs.readFile( String.raw`${{github.workspace}}/build/actions/out/` + filename )
}
);
}
}
macos:
name: Build macOS (${{ matrix.portable }}), ${{ matrix.build_type }}, ${{ matrix.arch }}
runs-on: macos-12
strategy:
matrix:
build_type: [Debug, Release]
portable: [Portable, Non-Portable]
arch: [x86_64]
steps:
- uses: actions/checkout@v3
with:
submodules: true
fetch-depth: 0
- name: Set CMake parameters
id: cmakeargs
shell: bash
run: |
if [ "${{ matrix.portable }}" == "Portable" ]; then
echo 'PORTABLE=-DBuildPortableVersion=ON' >> $GITHUB_OUTPUT
else
echo 'PORTABLE=-DBuildPortableVersion=OFF' >> $GITHUB_OUTPUT
fi
- name: Create Build Environment
run: |
brew install sdl2
mkdir -p ${{github.workspace}}/build/actions
- name: Configure CMake
shell: bash
working-directory: ${{github.workspace}}/build/actions
run: cmake -G "Unix Makefiles" -DUseInternalLibs=ON ${{ steps.cmakeargs.outputs.PORTABLE }} -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} $GITHUB_WORKSPACE
- name: Build
working-directory: ${{github.workspace}}/build/actions
shell: bash
run: make
- name: Package
working-directory: ${{github.workspace}}/build/actions
shell: bash
run: make package
#- uses: 'actions/upload-artifact@v3'
# with:
# name: macOS Binaries (${{ matrix.portable }}), ${{ matrix.build_type }}, ${{ matrix.arch }}
# path: ${{github.workspace}}/build/actions/out/${{ matrix.build_type }}/*
- uses: 'actions/upload-artifact@v3'
if: ${{ matrix.build_type == 'Release' }}
with:
name: macOS Package (${{ matrix.portable }}), ${{ matrix.build_type }}, ${{ matrix.arch }}
path: |
${{github.workspace}}/build/actions/out/*.tar.gz
${{github.workspace}}/build/actions/out/*.dmg
# As actions/upload-release-asset seems to demand exact filenames and content types we use a script instead
- name: Upload Release
if: ${{ github.event_name == 'release' && matrix.build_type == 'Release' }}
uses: actions/github-script@v6
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const fs = require('fs').promises;
for ( let filename of await fs.readdir('${{github.workspace}}/build/actions/out/') )
{
if ( filename.endsWith('.tar.gz') || filename.endsWith('.dmg') )
{
await github.rest.repos.uploadReleaseAsset(
{
owner: context.repo.owner,
repo: context.repo.repo,
release_id: ${{ github.event.release.id }},
name: filename,
data: await fs.readFile( "${{github.workspace}}/build/actions/out/" + filename )
}
);
}
}
linux:
name: Build Linux (${{ matrix.portable }} - ${{ matrix.container_image }}), ${{ matrix.build_type }}
runs-on: ubuntu-22.04
strategy:
matrix:
container_image: ["ubuntu:16.04", "i386/ubuntu:16.04"]
build_type: [Debug, Release]
portable: [Portable, Non-Portable]
steps:
- uses: actions/checkout@v3
with:
submodules: true
fetch-depth: 0
- name: Determine parameters
id: parameters
shell: bash
run: |
if [ "${{ matrix.portable }}" == "Portable" ]; then
OPTIONS="-DUseInternalLibs=ON -DBuildPortableVersion=ON"
else
OPTIONS="-DUseInternalLibs=OFF -DBuildPortableVersion=OFF"
fi
[[ "${{ matrix.container_image}}" == i386* ]] && OPTIONS="$OPTIONS -DSystemProcessor=i386"
echo "OPTIONS=$OPTIONS" >> $GITHUB_OUTPUT
BINARTIFACTNAME=$(echo "Linux Binaries (${{ matrix.portable }} - ${{ matrix.container_image }}), ${{ matrix.build_type }}" | tr ":/" "-")
echo "BINARTIFACTNAME=$BINARTIFACTNAME" >> $GITHUB_OUTPUT
PKGARTIFACTNAME=$(echo "Linux Package (${{ matrix.portable }} - ${{ matrix.container_image }}), ${{ matrix.build_type }}" | tr ":/" "-")
echo "PKGARTIFACTNAME=$PKGARTIFACTNAME" >> $GITHUB_OUTPUT
- name: Create Build Environment
run: |
podman pull docker.io/${{ matrix.container_image }}
podman run --name buildenv -v ${{github.workspace}}:/jk2mv -td docker.io/${{ matrix.container_image }} /bin/bash
podman exec buildenv apt-get update
podman exec buildenv apt-get install -y git zip wget libfuse2 build-essential libsdl2-dev libgl1-mesa-dev libopenal-dev libjpeg-dev libpng-dev libminizip-dev cmake rpm
mkdir -p ${{github.workspace}}/build/actions
- name: Configure CMake
shell: bash
run: podman exec -w /jk2mv/build/actions buildenv cmake -G "Unix Makefiles" ${{ steps.parameters.outputs.OPTIONS }} -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} /jk2mv
- name: Build
shell: bash
run: podman exec -w /jk2mv/build/actions buildenv make
- name: Package
shell: bash
run: podman exec -w /jk2mv/build/actions buildenv make package
#- uses: 'actions/upload-artifact@v3'
# with:
# name: ${{ steps.parameters.outputs.BINARTIFACTNAME }}
# path: ${{github.workspace}}/build/actions/out/${{ matrix.build_type }}/*
- uses: 'actions/upload-artifact@v3'
if: ${{ matrix.build_type == 'Release' }}
with:
name: ${{ steps.parameters.outputs.PKGARTIFACTNAME }}
path: |
${{github.workspace}}/build/actions/out/*.tar.gz
${{github.workspace}}/build/actions/out/*.deb
${{github.workspace}}/build/actions/out/*.rpm
# As actions/upload-release-asset seems to demand exact filenames and content types we use a script instead
- name: Upload Release
if: ${{ github.event_name == 'release' && matrix.build_type == 'Release' }}
uses: actions/github-script@v6
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const fs = require('fs').promises;
for ( let filename of await fs.readdir('${{github.workspace}}/build/actions/out/') )
{
if ( filename.endsWith('.tar.gz') || filename.endsWith('.deb') || filename.endsWith('.rpm') )
{
await github.rest.repos.uploadReleaseAsset(
{
owner: context.repo.owner,
repo: context.repo.repo,
release_id: ${{ github.event.release.id }},
name: filename,
data: await fs.readFile( "${{github.workspace}}/build/actions/out/" + filename )
}
);
}
}