Skip to content

Commit bcd374b

Browse files
committed
Add workflow for building Dawn
1 parent 3de33cf commit bcd374b

File tree

1 file changed

+201
-0
lines changed

1 file changed

+201
-0
lines changed

.github/workflows/dawn.yaml

Lines changed: 201 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,201 @@
1+
name: Build Dawn WebGPU
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
channel:
7+
description: "Chromium channel for Dawn"
8+
required: false
9+
default: "canary"
10+
type: choice
11+
options:
12+
- stable
13+
- beta
14+
- canary
15+
16+
env:
17+
DAWN_CHANNEL: ${{ github.event.inputs.channel || 'canary' }}
18+
19+
jobs:
20+
get-dawn-source:
21+
runs-on: ubuntu-latest
22+
23+
steps:
24+
- name: Checkout code
25+
uses: actions/checkout@v4
26+
27+
- name: Set up Python
28+
uses: actions/setup-python@v4
29+
with:
30+
python-version: "3.11"
31+
32+
- name: Install dependencies
33+
run: |
34+
python -m pip install --upgrade pip
35+
cd Dawn
36+
pip install -r requirements.txt
37+
38+
- name: Get Dawn source
39+
run: |
40+
cd Dawn
41+
python ci_build_dawn.py get-dawn --channel ${{ env.DAWN_CHANNEL }}
42+
43+
- name: Upload Dawn source
44+
uses: actions/upload-artifact@v4
45+
with:
46+
name: dawn-source
47+
path: Dawn/dawn_source/
48+
retention-days: 1
49+
50+
- name: Read Dawn version
51+
id: read-version
52+
run: |
53+
cd Dawn
54+
value=$(jq -r '.chromium_channel' dawn_version.json)
55+
echo "chromium_channel=$value" >> $GITHUB_OUTPUT
56+
value=$(jq -r '.chromium_dawn_version' dawn_version.json)
57+
echo "chromium_dawn_version=$value" >> $GITHUB_OUTPUT
58+
value=$(jq -r '.chromium_dawn_hash' dawn_version.json)
59+
echo "chromium_dawn_hash=$value" >> $GITHUB_OUTPUT
60+
value=$(jq -r '.chromium_dawn_suffix' dawn_version.json)
61+
echo "chromium_dawn_suffix=$value" >> $GITHUB_OUTPUT
62+
63+
build-dawn:
64+
needs: get-dawn-source
65+
strategy:
66+
matrix:
67+
include:
68+
- platform: ubuntu-latest
69+
target: linux
70+
python-version: "3.11"
71+
- platform: macos-latest
72+
target: macosx
73+
python-version: "3.11"
74+
# - platform: windows-latest
75+
# target: windows
76+
# python-version: "3.11"
77+
- platform: macos-latest
78+
target: iphoneos
79+
python-version: "3.11"
80+
- platform: macos-latest
81+
target: iphonesimulator
82+
python-version: "3.11"
83+
84+
runs-on: ${{ matrix.platform }}
85+
86+
steps:
87+
- name: Checkout code
88+
uses: actions/checkout@v4
89+
90+
- name: Set up Python
91+
uses: actions/setup-python@v4
92+
with:
93+
python-version: ${{ matrix.python-version }}
94+
95+
- name: Install dependencies
96+
run: |
97+
python -m pip install --upgrade pip
98+
cd Dawn
99+
pip install -r requirements.txt
100+
101+
- name: Download Dawn source
102+
uses: actions/download-artifact@v4
103+
with:
104+
name: dawn-source
105+
path: Dawn/
106+
107+
- name: Build Dawn for ${{ matrix.target }}
108+
run: |
109+
cd Dawn
110+
python ci_build_dawn.py build-target --target ${{ matrix.target }}
111+
112+
- name: Upload build artifacts
113+
uses: actions/upload-artifact@v4
114+
with:
115+
name: dawn-build-${{ matrix.target }}
116+
path: Dawn/builds/
117+
retention-days: 1
118+
119+
create-bundle:
120+
needs: [build-dawn, get-dawn-source]
121+
runs-on: ubuntu-latest
122+
123+
steps:
124+
- name: Checkout code
125+
uses: actions/checkout@v4
126+
127+
- name: Set up Python
128+
uses: actions/setup-python@v4
129+
with:
130+
python-version: "3.11"
131+
132+
- name: Install dependencies
133+
run: |
134+
python -m pip install --upgrade pip
135+
cd Dawn
136+
pip install -r requirements.txt
137+
138+
- name: Download all build artifacts
139+
uses: actions/download-artifact@v4
140+
with:
141+
path: Dawn/builds/
142+
143+
- name: Create artifact bundle
144+
run: |
145+
cd Dawn
146+
python ci_build_dawn.py bundle
147+
148+
- name: Upload bundle artifact
149+
uses: actions/upload-artifact@v4
150+
with:
151+
name: dawn-webgpu-bundle
152+
path: Dawn/dawn_webgpu_${{needs.get-dawn-source.outputs.chromium_dawn_suffix}}.zip
153+
retention-days: 30
154+
155+
create-release:
156+
needs: [create-bundle, get-dawn-source]
157+
runs-on: ubuntu-latest
158+
if: startsWith(github.ref, 'refs/tags/')
159+
160+
steps:
161+
- name: Checkout code
162+
uses: actions/checkout@v4
163+
164+
- name: Download bundle artifact
165+
uses: actions/download-artifact@v4
166+
with:
167+
name: dawn-webgpu-bundle
168+
path: dawn-bundle/
169+
170+
- name: Create Release
171+
uses: actions/create-release@v1
172+
env:
173+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
174+
with:
175+
release_name: Dawn WebGPU from Chromium ${{ needs.get-dawn-source.outputs.chromium_dawn_version }}
176+
body: |
177+
Dawn WebGPU build matching Chromium ${{ needs.get-dawn-source.outputs.chromium_dawn_version }}.
178+
Built from Dawn hash: ${{ needs.get-dawn-source.outputs.chromium_dawn_hash }}
179+
180+
This release contains pre-built Dawn WebGPU libraries for multiple platforms:
181+
- linux (x86_64)
182+
- macosx (x86_64 + ARM64)
183+
- iphoneos (ARM64)
184+
- iphonesimulator (x86_64)
185+
186+
Built from Chromium channel: ${{ env.DAWN_CHANNEL }}
187+
draft: false
188+
prerelease: false
189+
190+
- name: Upload Release Assets
191+
run: |
192+
TAG="dawn-chromium-${{env.DAWN_CHANNEL}}-${{needs.get-dawn-source.outputs.chromium_dawn_version}}"
193+
if gh release view "$TAG" >/dev/null 2>&1; then
194+
echo "Release '$TAG' already exists. Skipping upload."
195+
else
196+
echo "Uploading to release: $TAG"
197+
cd dawn-bundle
198+
gh release upload $TAG dawn_webgpu_${{needs.get-dawn-source.outputs.chromium_dawn_suffix}}.zip --clobber
199+
fi
200+
env:
201+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)