-
-
Notifications
You must be signed in to change notification settings - Fork 289
430 lines (412 loc) · 14.6 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
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
name: Build
on:
push:
paths-ignore:
- '.github/**'
- '!.github/workflows/build.yml'
- 'README.md'
- 'ubuntu-win64-cross/**'
pull_request:
paths-ignore:
- '.github/**'
- '!.github/workflows/build.yml'
- 'README.md'
- 'ubuntu-win64-cross/**'
jobs:
Init:
name: Create source package
runs-on: ubuntu-latest
steps:
- name: Clone tree
uses: actions/checkout@v4
with:
fetch-depth: 0
# On push to master, increment patch version and create a new tag on release
- name: Increment patch version
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
run: |
git config user.name "nobody"
git config user.email "nobody@nowhere"
VERSION=$(git describe --tags --match 'v*' --abbrev=0 | xargs ./scripts/increment-semver.py)
git tag -a $VERSION -m $VERSION
echo "Generated new release version: $VERSION"
# GitHub treats the new tag as lightweight, so older tags will shadow the
# new tag. Recreate it as an annotated tag now so the version script picks
# it up properly.
- name: Annotate release tag
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
run: |
git config user.name "nobody"
git config user.email "nobody@nowhere"
VERSION=${GITHUB_REF/refs\/tags\//}
git tag -a -f $VERSION $VERSION -m $VERSION
echo "Recreated release tag: $VERSION"
- name: Create source package
run: |
./scripts/archive-source.sh src.tar
gzip -1 src.tar
- name: Upload source package artifact
uses: actions/upload-artifact@v4
with:
name: src.tar.gz
path: src.tar.gz
Windows:
name: Build for Windows (${{ matrix.configuration }}) on Ubuntu
runs-on: ubuntu-latest
needs: Init
strategy:
matrix:
include:
- configuration: Debug
build_param: --debug
artifact_name: xemu-win-debug
- configuration: Release
build_param:
artifact_name: xemu-win-release
env:
DOCKER_IMAGE_NAME: ghcr.io/xemu-project/xemu-win64-toolchain:sha-8152913
steps:
- name: Download source package
uses: actions/download-artifact@v4
with:
name: src.tar.gz
- name: Extract source package
run: tar xf src.tar.gz
- name: Initialize compiler cache
id: cache
uses: actions/cache@v4
with:
path: /tmp/xemu-ccache
key: cache-wincross-${{ runner.os }}-${{ matrix.configuration }}-${{ github.sha }}
restore-keys: cache-wincross-${{ runner.os }}-${{ matrix.configuration }}-
- name: Pull Docker image
run: docker pull $DOCKER_IMAGE_NAME
- name: Compile
run: |
mkdir -p /tmp/xemu-ccache
docker run --rm \
-v $PWD:/xemu -w /xemu \
-v /tmp/xemu-ccache:/tmp/xemu-ccache \
-e CCACHE_DIR=/tmp/xemu-ccache \
-e CCACHE_MAXSIZE=512M \
-u $(id -u):$(id -g) \
$DOCKER_IMAGE_NAME \
bash -c "ccache -z; ./build.sh -p win64-cross ${{ matrix.build_param }} && ccache -s"
- name: Upload build artifact
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.artifact_name }}
path: dist
# Generate a symbols package for Windows. Use cv2pdb to generate PDBs from
# DWARF and update + strip the executable. Re-package the original release
# and create symbols package.
WindowsPdb:
name: Generate PDB for Windows (${{ matrix.configuration }})
runs-on: windows-latest
needs: Windows
strategy:
matrix:
include:
- configuration: Debug
artifact_name: xemu-win-debug
- configuration: Release
artifact_name: xemu-win-release
steps:
- name: Download artifacts
uses: actions/download-artifact@v4
with:
name: ${{ matrix.artifact_name }}
path: ${{ matrix.artifact_name }}
- name: Generate PDB
run: |
Invoke-WebRequest -Uri "https://github.com/rainers/cv2pdb/releases/download/v0.52/cv2pdb-0.52.zip" -OutFile "cv2pdb.zip"
7z x -ocv2pdb -y cv2pdb.zip
cd ${{ matrix.artifact_name }}
../cv2pdb/cv2pdb64.exe xemu.exe
mkdir ../dist
7z a -tzip ../dist/${{ matrix.artifact_name }}.zip * "-xr!*.pdb"
7z a -tzip ../dist/${{ matrix.artifact_name }}-pdb.zip "-ir!*.pdb"
- name: Upload build artifact
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.artifact_name }}-pdb
path: dist
Ubuntu:
name: Build for Ubuntu (${{ matrix.configuration }})
runs-on: ubuntu-latest
needs: Init
strategy:
matrix:
include:
- configuration: Debug
build_param: --debug
artifact_name: xemu-ubuntu-debug
artifact_filename: xemu-ubuntu-debug.tgz
- configuration: Release
build_param:
artifact_name: xemu-ubuntu-release
artifact_filename: xemu-ubuntu-release.tgz
steps:
- name: Initialize compiler cache
id: cache
uses: actions/cache@v4
with:
path: /tmp/xemu-ccache
key: cache-${{ runner.os }}-${{ matrix.configuration }}-${{ github.sha }}
restore-keys: cache-${{ runner.os }}-${{ matrix.configuration }}-
- name: Download source package
uses: actions/download-artifact@v4
with:
name: src.tar.gz
- name: Extract source package
run: |
mkdir src
tar -C src -xf src.tar.gz
- name: Create debian changelog
run: |
pushd src
echo -e "\
xemu (1:$(cat XEMU_VERSION)-0) unstable; urgency=medium\n\
Built from $(cat XEMU_VERSION)\n\
-- Matt Borgerson <[email protected]> $(date -R)" > debian/changelog
popd
- name: Install dependencies
run: |
export DEBIAN_FRONTEND=noninteractive
sudo apt-get -qy update
sudo apt-get install ccache libfuse2
pushd src
sudo apt-get -qy build-dep .
- name: Compile
run: |
export CCACHE_DIR=/tmp/xemu-ccache
export CCACHE_MAXSIZE=512M
export PATH="/usr/lib/ccache:$PATH"
export XEMU_BUILD_OPTIONS="${{ matrix.build_param }} --extra-cflags='-fuse-ld=gold'"
ccache -z
# XXX: dpkg-genbuildinfo takes two minutes on GH runners. Nuke it for now.
sudo rm /usr/bin/dpkg-genbuildinfo
sudo ln -s /bin/true /usr/bin/dpkg-genbuildinfo
pushd src
dpkg-buildpackage --no-sign -b
popd
mkdir -p dist
mv *.deb *.ddeb dist
echo -e "\n\nCompiler Cache Stats:"
ccache -s
- name: Generate AppImage
run: |
wget --no-verbose https://github.com/linuxdeploy/linuxdeploy/releases/latest/download/linuxdeploy-x86_64.AppImage
chmod +x linuxdeploy-x86_64.AppImage
ar x dist/*.deb
mkdir appimage
tar -C appimage -xf data.tar*
install -DT src/xemu.metainfo.xml appimage/usr/share/metainfo/xemu.metainfo.xml
export VERSION=v$(cat src/XEMU_VERSION)
if [[ "${{ matrix.configuration }}" == "Debug" ]]; then
export VERSION=$VERSION-dbg
fi
./linuxdeploy-x86_64.AppImage --output appimage --appdir appimage
mv xemu-*.AppImage dist
- name: Bundle artifacts
run: |
tar -czvf ${{ matrix.artifact_filename }} --transform "s#^dist#xemu#" dist
- name: Upload build artifact
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.artifact_name }}
path: ${{ matrix.artifact_filename }}
macOS:
name: Build for macOS (${{ matrix.arch }}, ${{ matrix.configuration }})
runs-on: macOS-14
needs: Init
strategy:
matrix:
include:
- arch: x86_64
configuration: Debug
build_param: --debug -a x86_64
artifact_name: xemu-macos-x86_64-debug
artifact_filename: xemu-macos-x86_64-debug.zip
- arch: x86_64
configuration: Release
build_param: -a x86_64
artifact_name: xemu-macos-x86_64-release
artifact_filename: xemu-macos-x86_64-release.zip
- arch: arm64
configuration: Debug
build_param: --debug -a arm64
artifact_name: xemu-macos-arm64-debug
artifact_filename: xemu-macos-arm64-debug.zip
- arch: arm64
configuration: Release
build_param: -a arm64
artifact_name: xemu-macos-arm64-release
artifact_filename: xemu-macos-arm64-release.zip
steps:
- name: Download source package
uses: actions/download-artifact@v4
with:
name: src.tar.gz
- name: Extract source package
run: tar xf src.tar.gz
- uses: actions/[email protected]
with:
python-version: '3.12'
- name: Install dependencies
run: |
export HOMEBREW_NO_AUTO_UPDATE=1
export HOMEBREW_NO_INSTALL_CLEANUP=1
brew install \
ccache \
coreutils \
dylibbundler \
ninja
pip install pyyaml requests
- name: Initialize compiler, library cache
id: cache
uses: actions/cache@v4
with:
path: |
xemu-ccache
macos-pkgs
key: cache-${{ runner.os }}-${{ matrix.arch }}-${{ matrix.configuration }}-${{ github.sha }}
restore-keys: cache-${{ runner.os }}-${{ matrix.arch }}-${{ matrix.configuration }}-
- name: Compile
run: |
export CCACHE_DIR=${GITHUB_WORKSPACE}/xemu-ccache
export CCACHE_MAXSIZE=512M
export PATH="/usr/local/opt/ccache/libexec:$PATH"
ccache -z
./build.sh ${{ matrix.build_param }}
echo -e "\nCompiler Cache Stats:"
ccache -s
pushd dist
zip -r ../${{ matrix.artifact_filename }} *
popd
- name: Upload build artifact
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.artifact_name }}
path: ${{ matrix.artifact_filename }}
macOSUniversal:
name: Build macOS Universal Bundle (${{ matrix.configuration }})
runs-on: macOS-14
needs: [macOS]
strategy:
matrix:
configuration: ["debug", "release"]
steps:
- name: Download x86_64 build
uses: actions/download-artifact@v4
with:
name: xemu-macos-x86_64-${{ matrix.configuration }}
path: xemu-macos-x86_64-${{ matrix.configuration }}
- name: Download arm64 build
uses: actions/download-artifact@v4
with:
name: xemu-macos-arm64-${{ matrix.configuration }}
path: xemu-macos-arm64-${{ matrix.configuration }}
- name: Build Universal bundle
run: |
mkdir dist
for arch in x86_64 arm64; do
pushd xemu-macos-${arch}-${{ matrix.configuration }}
unzip xemu-macos-${arch}-${{ matrix.configuration }}.zip
popd
pushd dist
unzip -o ../xemu-macos-${arch}-${{ matrix.configuration }}/xemu-macos-${arch}-${{ matrix.configuration }}.zip
popd
done
pushd dist
rm xemu.app/Contents/MacOS/xemu
lipo -create -output xemu.app/Contents/MacOS/xemu \
../xemu-macos-x86_64-${{ matrix.configuration }}/xemu.app/Contents/MacOS/xemu \
../xemu-macos-arm64-${{ matrix.configuration }}/xemu.app/Contents/MacOS/xemu
codesign --force --deep --preserve-metadata=entitlements,requirements,flags,runtime --sign - xemu.app/Contents/MacOS/xemu
zip -r ../xemu-macos-universal-${{ matrix.configuration }}.zip *
popd
- name: Upload build artifact
uses: actions/upload-artifact@v4
with:
name: xemu-macos-universal-${{ matrix.configuration }}
path: xemu-macos-universal-${{ matrix.configuration }}.zip
Release:
if: github.event_name == 'push' && (github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags/v'))
runs-on: ubuntu-latest
needs: [Ubuntu, macOSUniversal, WindowsPdb]
steps:
- name: Download artifacts
uses: actions/download-artifact@v4
with:
path: dist
- name: Extract source package
run: tar xf dist/src.tar.gz/src.tar.gz
- name: Get release info
run: |
echo "XEMU_VERSION=$(cat XEMU_VERSION)" >> $GITHUB_ENV
- name: Extract Ubuntu artifacts
run: |
pushd dist/xemu-ubuntu-release
tar xvf xemu-ubuntu-release.tgz
popd
pushd dist/xemu-ubuntu-debug
tar xvf xemu-ubuntu-debug.tgz
popd
- name: Publish release
uses: softprops/action-gh-release@v1
with:
tag_name: v${{ env.XEMU_VERSION }}
name: v${{ env.XEMU_VERSION }}
prerelease: false
draft: false
files: |
dist/src.tar.gz/src.tar.gz
dist/xemu-win-debug-pdb/xemu-win-debug.zip
dist/xemu-win-debug-pdb/xemu-win-debug-pdb.zip
dist/xemu-win-release-pdb/xemu-win-release.zip
dist/xemu-win-release-pdb/xemu-win-release-pdb.zip
dist/xemu-macos-universal-release/xemu-macos-universal-release.zip
dist/xemu-macos-universal-debug/xemu-macos-universal-debug.zip
dist/xemu-ubuntu-release/xemu/xemu-v${{ env.XEMU_VERSION }}-x86_64.AppImage
dist/xemu-ubuntu-debug/xemu/xemu-v${{ env.XEMU_VERSION }}-dbg-x86_64.AppImage
- name: Trigger website update
uses: benc-uk/[email protected]
with:
workflow: build.yml
repo: xemu-project/xemu-website
token: ${{ secrets.XEMU_ROBOT_TOKEN }}
ref: master
# Sync archive version of source (including submodule code) to the
# ppa-snapshot branch to work around limitations of the Launchpad platform,
# namely: no network egress on package build, no custom scripting in source
# package creation.
PushToPPA:
name: Push to PPA Snapshot Branch
if: github.event_name == 'push' && (github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags/v'))
needs: [Ubuntu, macOSUniversal, WindowsPdb]
runs-on: ubuntu-latest
steps:
- name: Download source package
uses: actions/download-artifact@v4
with:
name: src.tar.gz
- name: Extract source package
run: |
mkdir src
tar -C src -xf src.tar.gz
- name: Integrate Debian packaging
run: |
pushd src
echo -e "\
xemu (1:$(cat XEMU_VERSION)-0) unstable; urgency=medium\n\
Built from $(cat XEMU_VERSION)\n\
-- Matt Borgerson <[email protected]> $(date -R)" > debian/changelog
popd
- name: Deploy source archive to branch
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./src
publish_branch: ppa-snapshot
force_orphan: true