Skip to content

Commit 58c6450

Browse files
authored
Merge pull request #2 from adobe/cuberoot/dawn-build-workflow
Enable Github actions for building Dawn
2 parents 9e6520e + f774080 commit 58c6450

File tree

3 files changed

+263
-2
lines changed

3 files changed

+263
-2
lines changed

.github/workflows/dawn.yaml

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

Dawn/dawn_source.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ def fetch_dawn_source(hash: str) -> None:
128128
DawnSourceDirectoryConfigurationError, DawnSourceToolsDirectoryNotFoundError, for Dawn Source directory errors
129129
"""
130130
# Remove destination directory if it exists
131-
dest_dir = pathlib.Path("dawn_source").resolve()
131+
dest_dir = get_dawn_path()
132132
if dest_dir.exists():
133133
shutil.rmtree(dest_dir)
134134

@@ -177,7 +177,7 @@ def remove_dawn_source() -> None:
177177
"""
178178
Remove the Dawn source directory and version file.
179179
"""
180-
dawn_source_dir = pathlib.Path("dawn_source").resolve()
180+
dawn_source_dir = get_dawn_path()
181181
if dawn_source_dir.exists():
182182
shutil.rmtree(dawn_source_dir)
183183

0 commit comments

Comments
 (0)