forked from dosbox-staging/dosbox-staging
-
Notifications
You must be signed in to change notification settings - Fork 4
338 lines (291 loc) · 11.5 KB
/
macos.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
name: macOS builds
on: [push, pull_request]
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
env:
CCACHE_DIR: "${{ github.workspace }}/.ccache"
CCACHE_MAXSIZE: "64M"
CCACHE_COMPRESS: "true"
CLAMDB_DIR: "/usr/local/Cellar/clamav"
jobs:
build_macos:
name: ${{ matrix.conf.name }} (${{ matrix.conf.arch }})
runs-on: ${{ matrix.conf.host }}
if: github.event_name != 'pull_request' || contains('dreamer,kcgen,ant-222,Wengier,kklobe', github.actor) == false
strategy:
fail-fast: false
matrix:
conf:
- name: Clang (macos-10.15)
host: macos-10.15
arch: x86_64
needs_deps: true
packages: meson
build_flags: -Dunit_tests=disabled
max_warnings: 0
- name: Clang
host: macos-latest
arch: x86_64
needs_deps: true
packages: meson
build_flags: -Dunit_tests=disabled
max_warnings: 0
- name: GCC 11
host: macos-latest
arch: x86_64
needs_deps: true
packages: gcc@11
build_flags: -Dunit_tests=disabled --native-file=.github/meson/native-gcc-11.ini
max_warnings: 0
- name: Clang, +tests
host: macos-latest
arch: x86_64
needs_deps: true
run_tests: true
max_warnings: -1
- name: Clang, +debugger
host: macos-latest
arch: x86_64
needs_deps: true
build_flags: -Dunit_tests=disabled -Denable_debugger=normal
max_warnings: 0
- name: Clang
host: [self-hosted, macOS, arm64, debug-builds]
arch: arm64
needs_deps: false
packages: meson
build_flags: -Dunit_tests=disabled
max_warnings: 0
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Prepare brew and compiler caches
if: matrix.conf.needs_deps
id: prep-caches
shell: bash
run: |
set -eu
BREW_DIR="$(brew --cache)"
DISCARD_DIR="${{ github.workspace }}/discard"
mkdir -p "$DISCARD_DIR"
mv -f "$BREW_DIR"/* "$DISCARD_DIR"
mkdir -p "$CCACHE_DIR"
echo "::set-output name=brew_dir::$BREW_DIR"
echo "::set-output name=ccache_dir::$CCACHE_DIR"
echo "::set-output name=today::$(date +%F)"
echo "::set-output name=name_hash::$(echo '${{ matrix.conf.name }} ${{ matrix.conf.arch }}' | shasum | cut -b-8)"
- uses: actions/cache@v2
if: matrix.conf.needs_deps
with:
path: ${{ steps.prep-caches.outputs.brew_dir }}
key: brew-cache-${{ matrix.conf.arch }}-${{ steps.prep-caches.outputs.today }}-1
restore-keys: brew-cache-${{ matrix.conf.arch }}-
- name: Install C++ compiler and libraries
if: matrix.conf.needs_deps
run: |
arch -arch=${{ matrix.conf.arch }} brew install \
${{ matrix.conf.packages }} \
$(cat ./.github/packages/macos-latest-brew.txt)
- uses: actions/cache@v2
if: matrix.conf.needs_deps
with:
path: ${{ steps.prep-caches.outputs.ccache_dir }}
key: ccache-macos-debug-${{ steps.prep-caches.outputs.name_hash }}-${{ steps.prep-caches.outputs.today }}-1
restore-keys: |
ccache-macos-debug-${{ steps.prep-caches.outputs.name_hash }}-
ccache-macos-debug-
- name: Cache subprojects
uses: actions/cache@v2
with:
path: subprojects/packagecache
key: subprojects-${{ hashFiles('subprojects/*.wrap') }}
- name: Log environment
run: arch -arch=${{ matrix.conf.arch }} ./scripts/log-env.sh
- run: arch -arch=${{ matrix.conf.arch }} meson setup ${{ matrix.conf.build_flags }} build
- name: Build
run: |
set -xo pipefail
arch -arch=${{ matrix.conf.arch }} meson compile -C build 2>&1 | tee build.log
- name: Run tests
if: matrix.conf.run_tests
run: arch -arch=${{ matrix.conf.arch }} meson test -C build --print-errorlogs
- name: Summarize warnings
if: matrix.conf.run_tests != true
env:
MAX_WARNINGS: ${{ matrix.conf.max_warnings }}
run: arch -arch=${{ matrix.conf.arch }} python3 ./scripts/count-warnings.py -lf build.log
build_macos_release:
name: Release build (${{ matrix.runner.arch }})
runs-on: ${{ matrix.runner.host }}
if: github.event_name != 'pull_request' || contains('dreamer,kcgen,ant-222,Wengier,kklobe', github.actor) == false
env:
MIN_SUPPORTED_MACOSX_DEPLOYMENT_TARGET: ${{ matrix.runner.minimum_deployment }}
strategy:
matrix:
runner:
- host: macos-10.15
arch: x86_64
build_flags: --native-file=.github/meson/macos-10.15-deployment-target.ini
minimum_deployment: '10.15'
needs_deps: true
needs_libintl_workaround: true
- host: [self-hosted, macOS, arm64, release-builds]
arch: arm64
minimum_deployment: '11.0'
needs_deps: false
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Prepare brew and compiler caches
if: matrix.runner.needs_deps
id: prep-caches
shell: bash
run: |
set -eu
BREW_DIR="$(brew --cache)"
DISCARD_DIR="${{ github.workspace }}/discard"
mkdir -p "$DISCARD_DIR"
mv -f "$BREW_DIR"/* "$DISCARD_DIR"
mkdir -p "$CCACHE_DIR"
echo "::set-output name=brew_dir::$BREW_DIR"
echo "::set-output name=ccache_dir::$CCACHE_DIR"
echo "::set-output name=today::$(date +%F)"
- uses: actions/cache@v2
if: matrix.runner.needs_deps
with:
path: ${{ steps.prep-caches.outputs.brew_dir }}
key: brew-cache-${{ matrix.runner.arch }}-${{ steps.prep-caches.outputs.today }}
restore-keys: brew-cache-${{ matrix.runner.arch }}-
- name: Install C++ compiler and libraries
if: matrix.runner.needs_deps
run: >-
arch -arch=${{ matrix.runner.arch }} brew install librsvg tree
ccache libpng meson opusfile sdl2 sdl2_net
- uses: actions/cache@v2
if: matrix.runner.needs_deps
with:
path: ${{ steps.prep-caches.outputs.ccache_dir }}
key: ccache-macos-release-${{ matrix.runner.arch }}-${{ steps.prep-caches.outputs.today }}-1
restore-keys: ccache-macos-release-${{ matrix.runner.arch }}-
- name: Cache subprojects
uses: actions/cache@v2
with:
path: subprojects/packagecache
key: subprojects-${{ hashFiles('subprojects/*.wrap') }}
- name: Log environment
run: arch -arch=${{ matrix.runner.arch }} ./scripts/log-env.sh
- name: Inject version string
run: |
set -x
git fetch --prune --unshallow
export VERSION=$(git describe --abbrev=5)
echo "VERSION=$VERSION" >> $GITHUB_ENV
# KLUDGE: Work-around for the scenario where glib's wrap links with libintl
# dynamically, which adds a dependency into a brew dynlib package (in /usr/local/..),
# which some users won't have. So we knockout libintl.dynlib (by removing gettext
# removal), however this also breaks git: so we do a mock-meson setup to fetch all the
# git wraps before knocking it. then we re-add gettext after the build, so git can work
# for subsequent steps.
#
- name: Fetch subprojects then remove libintl.8.dylib
if: matrix.runner.needs_libintl_workaround
run: |
set -ex
meson setup -Ddefault_library=static --wrap-mode=forcefallback -Dfluidsynth:try-static-deps=true build
git clone --depth 1 --branch "0.2" https://github.com/frida/proxy-libintl.git subprojects/proxy-libintl
brew uninstall -f --ignore-dependencies gettext
rm -rf build
- name: Setup release build
run: >-
arch -arch=${{ matrix.runner.arch }} meson setup
${{ matrix.conf.build_flags }}
--wrap-mode=forcefallback
-Dbuildtype=release
-Db_lto=true
-Db_asneeded=true
-Ddefault_library=static
-Dtry_static_libs=opusfile,sdl2,sdl2_net
-Dfluidsynth:try-static-deps=true
build
- name: Build
run: arch -arch=${{ matrix.runner.arch }} ninja -C build
- name: Reinstate libintl.8.dylib
if: matrix.runner.needs_libintl_workaround
run: brew install gettext
- name: Upload binary
uses: actions/upload-artifact@v2
with:
name: dosbox-${{ matrix.runner.arch }}
path: build/dosbox
publish_universal_build:
name: Publish universal build
needs: build_macos_release
runs-on: macos-10.15
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Inject version string
run: |
set -x
git fetch --prune --unshallow
export VERSION=$(git describe --abbrev=5)
echo "VERSION=$VERSION" >> $GITHUB_ENV
- name: Install brew depedencies
run: brew install librsvg
- name: Download binaries
uses: actions/download-artifact@v2
- name: Package
run: |
./scripts/create-package.sh \
-p macos \
-v "${{ env.VERSION }}" \
-f \
"$(pwd)" \
"$(pwd)"
- name: Create dmg
run: |
ln -s /Applications dist/
codesign -s "-" dist/dosbox-staging.app --force --deep -v
hdiutil create \
-volname "dosbox-staging" \
-srcfolder dist \
-ov -format UDZO "dosbox-staging-macOS-${{ env.VERSION }}.dmg"
- name: Clam AV scan
id: prep-clamdb
shell: bash
run: |
brew install clamav
clamscan --heuristic-scan-precedence=yes --recursive --infected dist || true
- name: Upload disk image
uses: actions/upload-artifact@v2
# GitHub automatically zips the artifacts, and there's no option
# to skip it or upload a file only.
with:
name: dosbox-staging-macOS-universal
path: dosbox-staging-macOS-${{ env.VERSION }}.dmg
# This job exists only to publish an artifact with version info when building
# from main branch, so snapshot build version will be visible on:
# https://dosbox-staging.github.io/downloads/devel/
#
publish_additional_artifacts:
name: Publish additional artifacts
needs: build_macos_release
runs-on: macos-latest
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
steps:
- uses: actions/checkout@v2
- name: Generate changelog
run: |
set +x
git fetch --unshallow
VERSION=$(git describe --abbrev=4)
echo "VERSION=$VERSION" >> $GITHUB_ENV
NEWEST_TAG=$(git describe --abbrev=0)
git log "$NEWEST_TAG..HEAD" > changelog-$VERSION.txt
- uses: actions/upload-artifact@v2
with:
# Keep exactly this artifact name; it's being used to propagate
# version info via GitHub REST API
name: changelog-${{ env.VERSION }}.txt
path: changelog-${{ env.VERSION }}.txt