-
Notifications
You must be signed in to change notification settings - Fork 352
92 lines (79 loc) · 2.74 KB
/
build-wasm-examples.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
name: Build WASM Examples
on:
workflow_dispatch:
env:
PER_PAGE: 50
jobs:
prepare-pages:
name: Get Pages
runs-on: ubuntu-latest
outputs:
pages: ${{ steps.pages.outputs.pages }}
steps:
- name: Checkout Bevy main branch
uses: actions/checkout@v4
with:
repository: 'bevyengine/bevy'
ref: 'latest'
- name: Get Pages
id: pages
run: |
example_count=`cat Cargo.toml | grep 'wasm = true' | wc -l`
page_count=$((example_count / ${{ env.PER_PAGE }} + 1))
echo "pages=`jq -n -c \"[range($page_count)]\"`" >> $GITHUB_OUTPUT
wasm-examples:
name: Build WASM Examples
needs: prepare-pages
runs-on: macos-latest
strategy:
matrix:
page: ${{ fromJSON(needs.prepare-pages.outputs.pages) }}
api: [webgl2, webgpu]
steps:
- name: Checkout Bevy latest tag
uses: actions/checkout@v4
with:
repository: 'bevyengine/bevy'
ref: 'latest'
- name: Setup Rust
uses: dtolnay/rust-toolchain@stable
with:
target: wasm32-unknown-unknown,x86_64-apple-darwin
- name: Install WASM tooling
run: |
cargo install --force wasm-bindgen-cli
mkdir ./binaryen
wget -qO- https://github.com/WebAssembly/binaryen/releases/download/version_114/binaryen-version_114-x86_64-macos.tar.gz | tar xvz --strip-components 1 -C ./binaryen binaryen-version_114
- name: Build WASM Examples
run: |
export PATH=$PATH:`pwd`/binaryen/bin
cargo run -p example-showcase -- --per-page ${{ env.PER_PAGE }} --page ${{ matrix.page }} build-wasm-examples --content-folder wasm-examples --api ${{ matrix.api }} --website-hacks --optimize-size
- name: Upload Generated Files
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.api }}-examples-${{ matrix.page }}
path: wasm-examples
cloudflare-upload:
name: Upload to Cloudflare
runs-on: ubuntu-latest
needs: wasm-examples
strategy:
matrix:
api: [webgl2, webgpu]
steps:
- name: Download all artifacts
uses: actions/download-artifact@v4
- name: Group examples in one folder
run: |
mkdir ${{ matrix.api }}
for file in ${{ matrix.api }}-examples-*
do
rsync -a $file/* ${{ matrix.api }}/
done
- name: Publish to Cloudflare Pages
uses: cloudflare/pages-action@v1
with:
apiToken: ${{ secrets.CLOUDFLARE_PAGES }}
accountId: 0e862a54d5c283c78d8d56adb6159df8
projectName: bevy-${{ matrix.api }}-examples
directory: ${{ matrix.api }}