forked from vgmtrans/vgmtrans
-
Notifications
You must be signed in to change notification settings - Fork 0
423 lines (380 loc) · 15 KB
/
build.yml
File metadata and controls
423 lines (380 loc) · 15 KB
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
name: Build
on:
workflow_dispatch:
env:
# Node 20 is deprecated, not all actions are ready.
# Dependabot will get them, for now force them to Node 24
# to silence warnings
FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: true
jobs:
prepare:
name: Prepare metadata
runs-on: ubuntu-slim
outputs:
artifact_label: ${{ steps.meta.outputs.artifact_label }}
build_id: ${{ steps.meta.outputs.build_id }}
short_sha: ${{ steps.meta.outputs.short_sha }}
windows_targets: ${{ steps.meta.outputs.windows_targets }}
steps:
- name: Compute build metadata
id: meta
uses: actions/github-script@v9
with:
script: |
const ref = context.ref || '';
const refName = ref.replace(/^refs\/(heads|tags)\//, '');
const isTag = ref.startsWith('refs/tags/');
const isPush = context.eventName === 'push';
let buildId;
let buildSuffix = '';
if (context.eventName === 'pull_request') {
buildId = context.sha.slice(0, 7);
buildSuffix = `pr${context.payload.pull_request.number}`;
} else if (isTag) {
buildId = refName;
} else {
buildId = context.sha.slice(0, 7);
buildSuffix = refName;
}
const sanitize = (value) => (value || '').replace(/\//g, '-');
const safeBuildId = sanitize(buildId);
const safeBuildSuffix = sanitize(buildSuffix);
const artifactLabel = safeBuildSuffix
? `${safeBuildId}-${safeBuildSuffix}`
: safeBuildId;
const windowsTargets = JSON.stringify(isPush ? ['x64-clang'] : ['x64', 'x64-clang']);
core.setOutput('artifact_label', artifactLabel);
core.setOutput('build_id', buildId);
core.setOutput('short_sha', context.sha.slice(0, 7));
core.setOutput('windows_targets', windowsTargets);
macos:
name: macOS 13.x+
needs: prepare
runs-on: ${{ (matrix.target == 'intel' && 'macos-15') || 'macos-15' }}
strategy:
matrix:
target: [ "intel", "arm64" ]
permissions:
id-token: write
contents: read
attestations: write
env:
HOMEBREW_PREFIX: ${{ (matrix.target == 'intel' && '/usr/local') || '/opt/homebrew' }}
ARTIFACT_BASENAME: ${{ format('VGMTrans-macOS-{0}-{1}', matrix.target, needs.prepare.outputs.artifact_label) }}
steps:
- uses: actions/checkout@v6
with:
submodules: recursive
show-progress: false
- name: Install Qt
uses: jurplel/install-qt-action@v4
with:
aqtversion: '==3.1.*'
version: '6.10.2'
host: 'mac'
target: 'desktop'
arch: 'clang_64'
modules: 'all'
- name: "Set PATH"
shell: bash
run: |
echo "/usr/local/bin" >> "$GITHUB_PATH"
- name: "Install xz 5.8.3"
shell: bash
run: |
curl -fsSL https://github.com/tukaani-project/xz/releases/download/v5.8.3/xz-5.8.3.tar.gz | tar xz
cd xz-5.8.3
configure_args=(--prefix="$HOMEBREW_PREFIX" --enable-static --disable-shared)
if [[ "${{ matrix.target }}" == "intel" ]]; then
export CFLAGS="-arch x86_64h -mmacosx-version-min=13.0"
export CXXFLAGS="-arch x86_64h -mmacosx-version-min=13.0"
export LDFLAGS="-arch x86_64h -mmacosx-version-min=13.0"
configure_args+=(--host=x86_64-apple-darwin)
else
export CFLAGS="-arch arm64 -mmacosx-version-min=13.0"
export CXXFLAGS="-arch arm64 -mmacosx-version-min=13.0"
export LDFLAGS="-arch arm64 -mmacosx-version-min=13.0"
fi
./configure "${configure_args[@]}"
make -j$(sysctl -n hw.logicalcpu)
sudo make install
- name: "Prepare build"
run: >
cmake --preset "macos-${{ matrix.target }}" \
-DCMAKE_PREFIX_PATH="$HOMEBREW_PREFIX" \
-DQT_DEBUG_FIND_PACKAGE=${{runner.debug == '1' && 'ON' || 'OFF' }} \
-DCMAKE_VERBOSE_MAKEFILE=${{runner.debug == '1' && 'ON' || 'OFF' }} \
-DCMAKE_FIND_DEBUG_MODE=${{runner.debug == '1' && 'ON' || 'OFF' }}
- name: "Build project"
run: |
cmake --build \
--preset "macos-${{ matrix.target }}-release" \
--target vgmtrans vgmtrans-shell
- name: "Install project"
run: |
export DESTDIR=$PWD/"build/macos-${{ matrix.target }}/dist"
cmake --build --preset "macos-${{ matrix.target }}-release" --target install
- name: "Checkout create-dmg"
uses: actions/checkout@v6
with:
repository: create-dmg/create-dmg
path: "./build/macos-${{ matrix.target }}/create-dmg"
ref: master
show-progress: false
- name: Build macOS DMG
shell: bash
working-directory: "build/macos-${{ matrix.target }}/"
run: |
./create-dmg/create-dmg \
--no-internet-enable \
--volname "VGMTrans" \
--volicon "dist/usr/local/VGMTrans.app/Contents/Resources/appicon.icns" \
--background "${{ github.workspace }}/bin/dmg/bg.tif" \
--text-size 12 \
--window-pos 400 400 \
--window-size 700 400 \
--icon-size 80 \
--icon "VGMTrans.app" 313 97 \
--hide-extension "VGMTrans.app" \
--app-drop-link 520 97 \
--add-file "Unblock & Sign" "${{ github.workspace }}/bin/dmg/selfsign" 313 280 \
--add-file "README.txt" "${{ github.workspace }}/bin/dmg/README.txt" 520 280 \
"${{ env.ARTIFACT_BASENAME }}.dmg" \
"dist/usr/local/"
- name: Generate artifact attestation
uses: actions/attest@v4
if: ${{ github.event_name == 'push' }}
with:
subject-name: ${{ env.ARTIFACT_BASENAME }}
subject-path: "build/macos-${{ matrix.target }}/${{ env.ARTIFACT_BASENAME }}.dmg"
- name: "Upload artifact"
uses: actions/upload-artifact@v7
with:
path: "build/macos-${{ matrix.target }}/${{ env.ARTIFACT_BASENAME }}.dmg"
archive: false
linux:
needs: prepare
runs-on: ubuntu-24.04
container:
image: ghcr.io/flathub-infra/flatpak-github-actions:kde-6.10
options: --privileged
name: Linux, x64
permissions:
id-token: write
contents: read
attestations: write
env:
ARTIFACT_BASENAME: ${{ format('VGMTrans-Linux-x86_64-{0}', needs.prepare.outputs.artifact_label) }}
steps:
- uses: actions/checkout@v6
with:
submodules: recursive
show-progress: false
- name: "Build Flatpak"
uses: flatpak/flatpak-github-actions/flatpak-builder@v6
with:
bundle: ${{ env.ARTIFACT_BASENAME }}.flatpak
manifest-path: build-aux/flatpak/io.github.vgmtrans.vgmtrans.yaml
cache-key: flatpak-builder-${{ github.sha }}
upload-artifact: false
- name: Run linter
run: |
flatpak install -y flathub org.flatpak.Builder
flatpak run --command=flatpak-builder-lint org.flatpak.Builder \
--gha-format \
--user-exceptions build-aux/flatpak/flatpak-exceptions.json \
manifest build-aux/flatpak/io.github.vgmtrans.vgmtrans.yaml
flatpak run --command=flatpak-builder-lint org.flatpak.Builder \
--gha-format \
--exceptions \
--user-exceptions build-aux/flatpak/flatpak-exceptions.json \
repo repo
shell: bash
- name: Generate artifact attestation
uses: actions/attest@v4
if: ${{ github.event_name == 'push' }}
with:
subject-name: ${{ env.ARTIFACT_BASENAME }}
subject-path: "${{ env.ARTIFACT_BASENAME }}.flatpak"
- name: "Upload artifact"
uses: actions/upload-artifact@v7
with:
path: ${{ env.ARTIFACT_BASENAME }}.flatpak
archive: false
windows:
needs: prepare
runs-on: windows-2022
strategy:
matrix:
# We don't want to ship two Windows builds to users and clang performance is superior.
# Keep MSVC coverage for pull requests only.
target: [ 'x64-clang' ]
permissions:
id-token: write
contents: read
attestations: write
env:
PACKAGE_FILE_NAME: ${{ format('VGMTrans-Windows-{0}-{1}', matrix.target == 'x64-clang' && 'x64' || 'x64-msvc', needs.prepare.outputs.artifact_label) }}
steps:
- uses: actions/checkout@v6
with:
submodules: recursive
show-progress: false
- name: "Source vcvars for ${{ matrix.target }}"
if: ${{ !contains(matrix.target, '-clang') }}
uses: ilammy/msvc-dev-cmd@v1
with:
arch: ${{ matrix.target != 'x64' && (format('{0}_{1}', 'amd64', matrix.target)) || matrix.target }}
- name: Install Qt
uses: jurplel/install-qt-action@v4
with:
aqtversion: '==3.1.*'
version: '6.10.2'
host: 'windows'
target: 'desktop'
arch: 'win64_msvc2022_64'
modules: 'all'
- name: "Install xz 5.8.3"
run: |
curl -fsSL -o xz.tar.gz https://github.com/tukaani-project/xz/releases/download/v5.8.3/xz-5.8.3.tar.gz
tar xzf xz.tar.gz
cd xz-5.8.3
cmake -B build `
-DCMAKE_BUILD_TYPE=Release `
-DCMAKE_INSTALL_PREFIX="C:/xz" `
-DBUILD_SHARED_LIBS=OFF
cmake --build build --config Release --target install
- name: "Prepare build"
run: |
# Force to have a flat install package layout.
# Windows users get frightened at the sight of GNU directories.
cmake --preset win-${{ matrix.target }} `
-DINSTALL_CHANGELOG=ON `
-DCMAKE_PREFIX_PATH="C:/xz" `
-DQT_DEBUG_FIND_PACKAGE=${{runner.debug == '1' && 'ON' || 'OFF' }} `
-DCMAKE_VERBOSE_MAKEFILE=${{runner.debug == '1' && 'ON' || 'OFF' }} `
-DCMAKE_FIND_DEBUG_MODE=${{runner.debug == '1' && 'ON' || 'OFF' }} `
-DCMAKE_INSTALL_PREFIX="${{ github.workspace }}/dist" `
-DCMAKE_INSTALL_BINDIR="." `
-DCMAKE_INSTALL_LIBDIR="lib" `
-DCPACK_PACKAGE_FILE_NAME="${{ env.PACKAGE_FILE_NAME }}"
- name: "Build project"
run: |
cmake --build `
--preset win-${{ matrix.target }}-release `
--target vgmtrans vgmtrans-shell
- name: "Package project"
run: |
cmake --build `
--preset win-${{ matrix.target }}-release `
--target package
- name: Generate artifact attestation
uses: actions/attest@v4
if: ${{ github.event_name == 'push' }}
with:
subject-path: "build/win-${{ matrix.target }}/${{ env.PACKAGE_FILE_NAME }}.zip"
- name: "Upload artifact"
uses: actions/upload-artifact@v7
with:
path: "build/win-${{ matrix.target }}/${{ env.PACKAGE_FILE_NAME }}.zip"
archive: false
release:
name: Draft release
if: ${{ github.event_name == 'push' && startsWith(github.ref, 'refs/tags/') }}
runs-on: ubuntu-slim
needs: [prepare, macos, linux, windows]
permissions:
contents: write
steps:
- uses: actions/checkout@v6
with:
show-progress: false
- name: Download build artifacts
uses: actions/download-artifact@v8
with:
path: release-assets
skip-decompress: true
- name: Generate release notes
run: >
python3 build-aux/build-changelog.py
--input CHANGELOG.md
--current-version "${{ needs.prepare.outputs.build_id }}"
--format markdown
--no-heading
--output release-notes.md
- name: Create draft release
env:
GH_TOKEN: ${{ github.token }}
shell: bash
run: |
mapfile -d '' release_files < <(find release-assets -type f -print0)
gh release create "${{ needs.prepare.outputs.build_id }}" \
"${release_files[@]}" \
--draft \
--title "VGMTrans ${{ needs.prepare.outputs.build_id }}" \
--notes-file release-notes.md \
--verify-tag
preview-release:
name: VGMTrans Preview prerelease
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/master' }}
runs-on: ubuntu-slim
needs: [prepare, macos, linux, windows]
permissions:
contents: write
env:
VGMTRANS_PREVIEW_REPOSITORY: ${{ github.repository }}
VGMTRANS_PREVIEW_TAG: unstable
VGMTRANS_PREVIEW_TARGET: master
VGMTRANS_PREVIEW_VERSION: ${{ needs.prepare.outputs.short_sha }}
steps:
- uses: actions/checkout@v6
with:
show-progress: false
- name: Download build artifacts
uses: actions/download-artifact@v8
with:
path: release-assets
skip-decompress: true
- name: Generate release notes
env:
SOURCE_BRANCH: ${{ github.ref_name }}
SOURCE_REPOSITORY: ${{ github.repository }}
SOURCE_SHA: ${{ github.sha }}
shell: bash
run: |
python3 build-aux/build-changelog.py \
--input CHANGELOG.md \
--current-version Unreleased \
--format markdown \
--no-heading \
--output preview-release-notes.md
{
printf '> [!WARNING]\n'
printf '> These are test builds and may be less stable than the [current](https://github.com/vgmtrans/vgmtrans/releases) VGMTrans release. They may include bugs, but they can also contain new features and fixes not yet available in the latest stable release.\n\n'
cat preview-release-notes.md
} > preview-release-notes.tmp
mv preview-release-notes.tmp preview-release-notes.md
{
printf "\n## Build info\n"
printf -- "- Source commit: [\`%s\`](https://github.com/%s/commit/%s)\n" \
"$SOURCE_SHA" "$SOURCE_REPOSITORY" "$SOURCE_SHA"
printf -- "- Source branch: \`%s\`\n" "$SOURCE_BRANCH"
} >> preview-release-notes.md
- name: Replace preview prerelease
env:
GH_TOKEN: ${{ github.token }}
shell: bash
run: |
mapfile -d '' release_files < <(find release-assets -type f -print0)
if gh release view "$VGMTRANS_PREVIEW_TAG" --repo "$VGMTRANS_PREVIEW_REPOSITORY" >/dev/null 2>&1; then
gh release delete "$VGMTRANS_PREVIEW_TAG" \
--repo "$VGMTRANS_PREVIEW_REPOSITORY" \
--cleanup-tag \
--yes
fi
gh release create "$VGMTRANS_PREVIEW_TAG" \
"${release_files[@]}" \
--repo "$VGMTRANS_PREVIEW_REPOSITORY" \
--target "$VGMTRANS_PREVIEW_TARGET" \
--title "VGMTrans Preview $VGMTRANS_PREVIEW_VERSION" \
--notes-file preview-release-notes.md