forked from ruffle-rs/ruffle
-
Notifications
You must be signed in to change notification settings - Fork 0
575 lines (496 loc) · 21.2 KB
/
release_nightly.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
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
name: Release Nightly
permissions:
contents: write
on:
# Run nightly
schedule:
- cron: "0 0 * * *"
# Allow for manual dispatch on GitHub
workflow_dispatch:
jobs:
create-nightly-release:
name: Create Nightly Release
runs-on: ubuntu-22.04
outputs:
is_active: ${{ steps.activity.outputs.is_active }}
date: ${{ steps.current_time_dashes.outputs.formattedTime }}
upload_url: ${{ steps.create_release.outputs.upload_url }}
package_prefix: Ruffle_Nightly_${{ steps.current_time_dashes.outputs.formattedTime }}
tag_name: nightly-${{ steps.current_time_dashes.outputs.formattedTime }}
# Only run the scheduled workflows on the main repo.
if: github.repository == 'ruffle-rs/ruffle' || github.event_name == 'repository_dispatch' ||
github.event_name == 'workflow_dispatch'
steps:
- uses: actions/checkout@v4
- name: Check for repo activity
id: activity
run: |
# Skip activity check when manually triggered.
if [ "${{ github.event_name }}" == "repository_dispatch" ] || [ "${{ github.event_name }}" == "workflow_dispatch" ]; then
is_active=true
elif [ "$(git rev-list --after="24 hours" ${{ github.sha }})" ]; then
is_active=true
else
is_active=false
fi
echo "is_active=$is_active" >> $GITHUB_OUTPUT
- name: Get current time with dashes
uses: 1466587594/[email protected]
id: current_time_dashes
with:
format: YYYY-MM-DD
- name: Create release
if: steps.activity.outputs.is_active == 'true'
id: create_release
run: |
tag_name="nightly-${{ steps.current_time_dashes.outputs.formattedTime }}"
release_name="Nightly ${{ steps.current_time_dashes.outputs.formattedTime }}"
gh release create "$tag_name" --title "$release_name" --generate-notes --prerelease
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
build:
name: Build ${{ matrix.build_name }}
needs: [create-nightly-release, build-web]
if: needs.create-nightly-release.outputs.is_active == 'true'
strategy:
fail-fast: false
matrix:
include:
- build_name: Linux_x86-64
os: ubuntu-22.04
# Mac does two Rust builds to make a universal binary
- build_name: macOS_x86-64
os: macos-14
target: x86_64-apple-darwin
MIN_MACOS_VERSION: 10.12
DESKTOP_FEATURES: sandbox,jpegxr
- build_name: macOS_arm64
os: macos-14
target: aarch64-apple-darwin
MIN_MACOS_VERSION: 11.0
DESKTOP_FEATURES: sandbox,jpegxr
- build_name: Windows_x86-32
os: windows-latest
target: i686-pc-windows-msvc
RUSTFLAGS: -Ctarget-feature=+crt-static
DESKTOP_FEATURES: jpegxr
- build_name: Windows_x86-64
os: windows-latest
target: x86_64-pc-windows-msvc
RUSTFLAGS: -Ctarget-feature=+crt-static
DESKTOP_FEATURES: jpegxr
env:
PACKAGE_FILE: |-
${{ needs.create-nightly-release.outputs.package_prefix }}_${{ matrix.build_name }}.${{
startsWith(matrix.build_name, 'macos') && 'dmg' ||
startsWith(matrix.build_name, 'linux') && 'tar.gz' ||
'zip'
}}
CARGO_BUILD_DIR: target/${{ matrix.target }}/release
runs-on: ${{ matrix.os }}
# Use the oldest still-supported LTS version to build the AppImage
container: ${{ startsWith(matrix.build_name, 'linux') && 'ubuntu:20.04' || null }}
steps:
# Necessary when using an Ubuntu container as it doesn't contain required shell tools
# TODO: Replace with AppImageDeploy container
- name: Install shell tools (Linux)
if: runner.os == 'Linux'
run: |
apt update
DEBIAN_FRONTEND=noninteractive TZ=Etc/UTC apt -y install tzdata
apt install -y git gcc default-jre wget curl sudo
git config --global --add safe.directory *
curl -sS https://webi.sh/gh | sh
ln -s ~/.local/bin/gh /usr/local/bin
- name: Clone Ruffle repo
uses: actions/checkout@v4
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
toolchain: stable
targets: ${{ matrix.target }}
- name: Install Linux dependencies
if: runner.os == 'Linux'
run: |
sudo apt update
sudo apt install -y libasound2-dev libxcb-shape0-dev libxcb-xfixes0-dev libgtk-3-dev libudev-dev
- name: Cargo build
run: cargo build --locked --package ruffle_desktop --release ${{matrix.DESKTOP_FEATURES && '--features' }}
${{matrix.DESKTOP_FEATURES}} ${{ matrix.target && '--target' }} ${{ matrix.target }}
env:
RUSTFLAGS: ${{ matrix.RUSTFLAGS }}
MACOSX_DEPLOYMENT_TARGET: ${{ matrix.MIN_MACOS_VERSION }}
- name: Package common files
run: |
mkdir package
mkdir common_package
cp README.md common_package/README.md
cp LICENSE.md common_package/LICENSE.md
- name: Package Windows files
if: runner.os == 'Windows'
run: |
cp common_package/* package
cp "${{ env.CARGO_BUILD_DIR }}/ruffle_desktop.exe" package/ruffle.exe
7z a "${{ env.PACKAGE_FILE }}" ./package/*
- name: Create an AppImage (Linux)
if: runner.os == 'Linux'
run: |
wget https://github.com/linuxdeploy/linuxdeploy/releases/download/continuous/linuxdeploy-x86_64.AppImage
chmod +x linuxdeploy-x86_64.AppImage
# TODO Update this after https://github.com/linuxdeploy/linuxdeploy/pull/288 gets merged
mkdir -p AppDir/usr/share
cp desktop/packaging/Linux/rs.ruffle.Ruffle.metainfo.xml AppDir/rs.ruffle.Ruffle.appdata.xml
cp common_package/* AppDir/usr/share
LDAI_OUTPUT="Ruffle.AppImage" ./linuxdeploy-x86_64.AppImage --appimage-extract-and-run \
-e "${{ env.CARGO_BUILD_DIR }}/ruffle_desktop" -d desktop/packaging/Linux/rs.ruffle.Ruffle.desktop \
-i desktop/assets/icon.svg -i desktop/packaging/Linux/icon.png --appdir AppDir --output appimage
cp Ruffle.AppImage package/Ruffle.AppImage
- name: Package Linux files
if: runner.os == 'Linux'
run: |
cp common_package/* package
# We must enter the package/ directory in order to create a flat tarball (i.e. without a directory in it).
cd package
tar -czvf "../${{ env.PACKAGE_FILE }}" *
- name: Build Safari Web Extension stub binary
if: runner.os == 'macOS'
run: cargo build --locked --package ruffle_web_safari --release ${{ matrix.target && '--target' }} ${{ matrix.target }}
env:
RUSTFLAGS: ${{ matrix.RUSTFLAGS }}
MACOSX_DEPLOYMENT_TARGET: ${{ matrix.MIN_MACOS_VERSION }}
- name: Download Safari extension zip file
uses: actions/download-artifact@v4
with:
name: macos-safari
- name: Package macOS files
if: runner.os == 'macOS'
run: source ./.github/reusable/package_macOS_executable.sh
"${{ env.CARGO_BUILD_DIR }}/ruffle_desktop" "${{ env.CARGO_BUILD_DIR }}/ruffle_web_safari"
"ruffle_extension.zip" "${{ startsWith(matrix.target, 'x86_64') && 'true' || 'false' }}"
"${{ matrix.MIN_MACOS_VERSION }}" "${{ env.PACKAGE_FILE }}"
env:
APPLE_DEVELOPER_KEY: ${{ secrets.APPLE_DEVELOPER_KEY }}
APPLE_DEVELOPER_KEY_PASSWORD: ${{ secrets.APPLE_DEVELOPER_KEY_PASSWORD }}
APPLE_DEVELOPER_IDENTITY: ${{ secrets.APPLE_DEVELOPER_IDENTITY }}
APPLE_ID: ${{ secrets.APPLE_ID }}
APPLE_TEAM: ${{ secrets.APPLE_TEAM }}
APPLE_APP_PASSWORD: ${{ secrets.APPLE_APP_PASSWORD }}
- name: Upload package
run: gh release upload "${{ needs.create-nightly-release.outputs.tag_name }}" "${{ env.PACKAGE_FILE }}"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Upload macOS build artifact
if: runner.os == 'macOS'
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.build_name }}
path: |
${{ env.CARGO_BUILD_DIR }}/ruffle_desktop
${{ env.CARGO_BUILD_DIR }}/ruffle_web_safari
common_package
build-mac-universal-binary:
name: Build macOS universal binary
needs: [create-nightly-release, build, build-web]
runs-on: macos-14
env:
PACKAGE_FILE: ${{ needs.create-nightly-release.outputs.package_prefix }}_macOS_Universal.dmg
INTEL_BINARY_PATH: target/x86_64-apple-darwin/release
ARM_BINARY_PATH: target/aarch64-apple-darwin/release
MIN_MACOS_VERSION: 10.12
steps:
- name: Clone Ruffle repo
uses: actions/checkout@v4
- name: Download arm64 binary
uses: actions/download-artifact@v4
with:
name: macOS_arm64
- name: Download x86-64 binary
uses: actions/download-artifact@v4
with:
name: macOS_x86-64
- name: Download Safari extension zip file
uses: actions/download-artifact@v4
with:
name: macos-safari
- name: Make universal desktop binary
run: |
mkdir package
lipo -create -output package/ruffle "${{ env.INTEL_BINARY_PATH }}/ruffle_desktop" \
"${{ env.ARM_BINARY_PATH }}/ruffle_desktop"
chmod +x package/ruffle
- name: Make universal Safari stub binary
continue-on-error: true
run: |
lipo -create -output package/ruffle_web_safari "${{ env.INTEL_BINARY_PATH }}/ruffle_web_safari" \
"${{ env.ARM_BINARY_PATH }}/ruffle_web_safari"
chmod +x package/ruffle_web_safari
- name: Package macOS files
run: source ./.github/reusable/package_macOS_executable.sh
package/ruffle package/ruffle_web_safari ruffle_extension.zip true "${{ env.MIN_MACOS_VERSION }}"
"${{ env.PACKAGE_FILE }}"
env:
APPLE_DEVELOPER_KEY: ${{ secrets.APPLE_DEVELOPER_KEY }}
APPLE_DEVELOPER_KEY_PASSWORD: ${{ secrets.APPLE_DEVELOPER_KEY_PASSWORD }}
APPLE_DEVELOPER_IDENTITY: ${{ secrets.APPLE_DEVELOPER_IDENTITY }}
APPLE_ID: ${{ secrets.APPLE_ID }}
APPLE_TEAM: ${{ secrets.APPLE_TEAM }}
APPLE_APP_PASSWORD: ${{ secrets.APPLE_APP_PASSWORD }}
- name: Upload package
run: gh release upload "${{ needs.create-nightly-release.outputs.tag_name }}" "${{ env.PACKAGE_FILE }}"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
build-stub-report:
name: Build AVM2 stub repository
needs: create-nightly-release
if: needs.create-nightly-release.outputs.is_active == 'true'
runs-on: ubuntu-22.04
steps:
- name: Clone Ruffle repo
uses: actions/checkout@v4
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
toolchain: stable
- name: Generate report
run: ./stub-report/generate-report.sh
- name: Upload report
run: gh release upload "${{ needs.create-nightly-release.outputs.tag_name }}" avm2_report.json
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
build-web:
name: Build web${{ matrix.demo && ' demo' || '' }}
needs: create-nightly-release
if: needs.create-nightly-release.outputs.is_active == 'true'
runs-on: ubuntu-22.04
strategy:
matrix:
demo: [false, true]
steps:
- name: Clone Ruffle repo
uses: actions/checkout@v4
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
toolchain: stable
targets: wasm32-unknown-unknown
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: "20"
registry-url: https://registry.npmjs.org
# wasm-bindgen-cli version must match wasm-bindgen crate version.
# Be sure to update in test_web.yml, web/Cargo.toml and web/README.md.
- name: Install wasm-bindgen
run: cargo install wasm-bindgen-cli --version 0.2.92
# Keep the version number in sync in all workflows,
# and in the extension builder Dockerfile!
- name: Install wasm-opt
uses: sigoden/install-binary@v1
with:
repo: WebAssembly/binaryen
tag: version_118
name: wasm-opt
- name: Install node packages
working-directory: web
shell: bash -l {0}
run: |
npm ci
- name: Seal version data
shell: bash -l {0}
working-directory: web
env:
BUILD_ID: ${{ github.run_number }}
ENABLE_VERSION_SEAL: "true"
FIREFOX_EXTENSION_ID: ${{ secrets.FIREFOX_EXTENSION_ID }} # Needed to inject into manifest.json
run: npm run version-seal
- name: Build web
env:
BUILD_ID: ${{ github.run_number }}
# Build web demo with WebGPU support for testing in Chrome origin trial on ruffle.rs
CARGO_FEATURES: jpegxr${{ matrix.demo && ',webgpu' || '' }}
FIREFOX_EXTENSION_ID: ${{ secrets.FIREFOX_EXTENSION_ID }} # Needed to inject into manifest.json
WASM_SOURCE: cargo_and_store
working-directory: web
shell: bash -l {0}
run: npm run build:repro
- name: Produce reproducible source archive
if: ${{ !matrix.demo }}
shell: bash -l {0}
run: |
zip -r Reproducible-Source.zip . -x '/web/node_modules/*' '/web/*/node_modules/*' '/web/packages/*/dist/*' \
'/web/docker/docker_builds/packages/*' '/target/*' '/.git/*' '/tests/tests/swfs/*'
cp Reproducible-Source.zip "${{ needs.create-nightly-release.outputs.package_prefix }}_Reproducible-Source.zip"
- name: Upload reproducible source archive
if: ${{ !matrix.demo }}
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GH_REPO: ${{ github.repository }}
run: |
tag_name="${{ needs.create-nightly-release.outputs.tag_name }}"
package_file="${{ needs.create-nightly-release.outputs.package_prefix }}_Reproducible-Source.zip"
gh release upload "$tag_name" "$package_file"
- name: Build web docs
working-directory: web
run: npm run docs
- name: Publish npm package
if: ${{ !matrix.demo }}
# npm scoped packages are private by default, explicitly make public
run: npm publish --access public
continue-on-error: true
working-directory: web/packages/selfhosted/dist
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Package selfhosted
if: ${{ !matrix.demo }}
run: zip -r "${{ needs.create-nightly-release.outputs.package_prefix }}_Web-Selfhosted.zip" .
working-directory: web/packages/selfhosted/dist
- name: Upload selfhosted
if: ${{ !matrix.demo }}
run: |
tag_name="${{ needs.create-nightly-release.outputs.tag_name }}"
package_file="${{ needs.create-nightly-release.outputs.package_prefix }}_Web-Selfhosted.zip"
gh release upload "$tag_name" "$package_file"
working-directory: web/packages/selfhosted/dist
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Upload generic extension
if: ${{ !matrix.demo }}
run: |
tag_name="${{ needs.create-nightly-release.outputs.tag_name }}"
package_file="${{ needs.create-nightly-release.outputs.package_prefix }}_Web-Extension.zip"
cp "./web/packages/extension/dist/ruffle_extension.zip" "$package_file"
gh release upload "$tag_name" "$package_file"
rm "$package_file"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Upload Safari build artifacts
if: ${{ !matrix.demo }}
uses: actions/upload-artifact@v4
with:
name: macos-safari
path: ./web/packages/extension/dist/ruffle_extension.zip
- name: Upload Firefox extension (unsigned)
if: ${{ !matrix.demo }}
run: |
tag_name="${{ needs.create-nightly-release.outputs.tag_name }}"
package_file="${{ needs.create-nightly-release.outputs.package_prefix }}_Web-Extension_Firefox-Unsigned.xpi"
cp "./web/packages/extension/dist/Firefox_Unsigned.xpi" "$package_file"
gh release upload "$tag_name" "$package_file"
rm "$package_file"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Publish Chrome extension
if: env.CHROME_EXTENSION_ID != '' && !matrix.demo
id: publish-chrome-extension
continue-on-error: true
env:
CHROME_EXTENSION_ID: ${{ secrets.CHROME_EXTENSION_ID }}
uses: mnao305/[email protected]
with:
extension-id: ${{ secrets.CHROME_EXTENSION_ID }}
client-id: ${{ secrets.CHROME_CLIENT_ID }}
client-secret: ${{ secrets.CHROME_CLIENT_SECRET }}
refresh-token: ${{ secrets.CHROME_REFRESH_TOKEN }}
file-path: ./web/packages/extension/dist/ruffle_extension.zip
- name: Publish Edge extension
if: env.EDGE_PRODUCT_ID != '' && !matrix.demo
id: publish-edge-extension
continue-on-error: true
env:
EDGE_PRODUCT_ID: ${{ secrets.EDGE_PRODUCT_ID }}
uses: wdzeng/edge-addon@v1
with:
product-id: ${{ secrets.EDGE_PRODUCT_ID }}
zip-path: ./web/packages/extension/dist/ruffle_extension.zip
client-id: ${{ secrets.EDGE_CLIENT_ID }}
client-secret: ${{ secrets.EDGE_CLIENT_SECRET }}
access-token-url: ${{ secrets.EDGE_ACCESS_TOKEN_URL }}
- name: Clone web demo
if: matrix.demo
uses: actions/checkout@v4
with:
repository: ruffle-rs/demo
path: demo
ref: master
fetch-depth: 0
persist-credentials: false # Needed to allow commit via RUFFLE_BUILD_TOKEN below
- name: Update web demo
if: matrix.demo
run: |
# Delete the old build.
rm -fr *
# Copy the fresh build into this folder.
cp -fr ../web/packages/demo/dist/* .
# Restore our custom swfs
git restore swfs swfs.json
# Create git commit. Amend previous commit to avoid daily commit spam.
git config user.name "RuffleBuild"
git config user.email "[email protected]"
git add -A
git commit --amend -m "Nightly build ${{ needs.create-nightly-release.outputs.date }}"
working-directory: demo
- name: Push web demo
if: github.repository == 'ruffle-rs/ruffle' && matrix.demo
uses: ad-m/github-push-action@master
with:
repository: ruffle-rs/demo
github_token: ${{ secrets.RUFFLE_BUILD_TOKEN }}
directory: demo
force: true
- name: Clone JS docs
if: ${{ !matrix.demo }}
uses: actions/checkout@v4
with:
repository: ruffle-rs/js-docs
path: js-docs
ref: master
fetch-depth: 0
persist-credentials: false # Needed to allow commit via RUFFLE_BUILD_TOKEN below
- name: Update JS docs
if: ${{ !matrix.demo }}
run: |
# Delete the old docs
rm -rf master/
# Copy the fresh docs into this folder.
cp -r ../web/packages/core/docs master
# Create git commit. Amend previous commit to avoid daily commit spam.
git config user.name "RuffleBuild"
git config user.email "[email protected]"
git add -A
git commit --amend -m "Nightly build ${{ needs.create-nightly-release.outputs.date }}"
working-directory: js-docs
- name: Push JS docs
if: github.repository == 'ruffle-rs/ruffle' && !matrix.demo
uses: ad-m/github-push-action@master
with:
repository: ruffle-rs/js-docs
github_token: ${{ secrets.RUFFLE_BUILD_TOKEN }}
directory: js-docs
force: true
publish-aur-package:
name: Publish AUR package
needs: [create-nightly-release, build]
runs-on: ubuntu-22.04
if: github.repository == 'ruffle-rs/ruffle'
steps:
- uses: actions/checkout@v4
- name: Download package
run: gh release download "${{ needs.create-nightly-release.outputs.tag_name }}"
--pattern "${{ needs.create-nightly-release.outputs.package_prefix }}_Linux_x86-64.tar.gz"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Update PKGBUILD
run: >
sed -i ./PKGBUILD
-e "s/@DASH_TIME@/${{ needs.create-nightly-release.outputs.date }}/"
-e "s/@SHA512SUM@/$(sha512sum ${{ needs.create-nightly-release.outputs.package_prefix }}_Linux_x86-64.tar.gz | \
cut -d' ' -f1)/"
- name: Publish AUR package
uses: KSXGitHub/[email protected]
with:
pkgname: ruffle-nightly-bin
pkgbuild: ./PKGBUILD
commit_username: RuffleBuild
commit_email: [email protected]
ssh_private_key: ${{ secrets.AUR_SSH_PRIVATE_KEY }}
commit_message: Update to Nightly ${{ needs.create-nightly-release.outputs.date }}