Skip to content

Commit 6b70b44

Browse files
fix: split publish-stage into native-only and pack-only phases (#128)
1 parent 1482268 commit 6b70b44

5 files changed

Lines changed: 251 additions & 79 deletions

File tree

.github/workflows/pr.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ jobs:
7979

8080
build-macos:
8181
name: Build (macOS)
82-
runs-on: macos-latest
82+
runs-on: macos-latest-large
8383
needs: lint
8484
steps:
8585
- uses: actions/checkout@v4

.github/workflows/publish.yml

Lines changed: 64 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -38,14 +38,15 @@ jobs:
3838
echo "should_publish=true" >> "$GITHUB_OUTPUT"
3939
fi
4040
41-
# ── Step 2: Build and stage all artifacts (3 runners, 2 targets each) ─
41+
# ── Step 2: Build and stage native artifacts (3 runners, 2 targets each) ─
4242
#
43-
# Each runner builds native + cross targets, then runs full publish-stage
44-
# to produce a complete publish/ folder for its platforms.
43+
# Each runner builds native + cross targets, then stages only the native files
44+
# for its platforms into package/runtime directories. The release job later
45+
# merges those staged files and packs npm/NuGet/crates/WASM once on Linux.
4546
#
46-
# ubuntu-latest (x64) → linux-x64 + linux-arm64
47-
# macos-latest (arm) → darwin-arm64 + darwin-x64
48-
# windows-latest (x64) → win32-x64 + win32-arm64
47+
# ubuntu-latest (x64) → linux-x64 + linux-arm64
48+
# macos-latest-large (arm) → darwin-arm64 + darwin-x64
49+
# windows-latest (x64) → win32-x64 + win32-arm64
4950

5051
build-linux:
5152
name: Build (Linux x64 + arm64)
@@ -58,7 +59,6 @@ jobs:
5859
with:
5960
shared-cache-key: publish-linux
6061
rust-targets: x86_64-unknown-linux-gnu, aarch64-unknown-linux-gnu
61-
dotnet: '8.0.x'
6262
skip-build: 'true'
6363

6464
- name: Install cross-compilation tools (arm64 linker)
@@ -82,28 +82,32 @@ jobs:
8282
-p microsoft-webui-ffi
8383
-p microsoft-webui-node
8484
85-
- name: Stage all artifacts
86-
run: cargo xtask publish-stage --target all --profile release
85+
- name: Stage native artifacts
86+
run: cargo xtask publish-stage --target all --profile release --native-only
8787

88-
- name: Upload publish folder
88+
- name: Upload staged native assets
8989
uses: actions/upload-artifact@v4
9090
with:
91-
name: publish-linux
92-
path: publish/
91+
name: stage-linux
92+
path: |
93+
publish/native/
94+
packages/webui-linux-x64/
95+
packages/webui-linux-arm64/
96+
dotnet/runtimes/linux-x64/
97+
dotnet/runtimes/linux-arm64/
9398
retention-days: 1
9499

95100
build-macos:
96101
name: Build (macOS arm64 + x64)
97102
needs: check-version
98103
if: needs.check-version.outputs.should_publish == 'true'
99-
runs-on: macos-latest
104+
runs-on: macos-latest-large
100105
steps:
101106
- uses: actions/checkout@v4
102107
- uses: ./.github/actions/build
103108
with:
104109
shared-cache-key: publish-macos
105110
rust-targets: aarch64-apple-darwin, x86_64-apple-darwin
106-
dotnet: '8.0.x'
107111
skip-build: 'true'
108112

109113
- name: Build arm64 (native)
@@ -122,14 +126,19 @@ jobs:
122126
-p microsoft-webui-ffi
123127
-p microsoft-webui-node
124128
125-
- name: Stage all artifacts
126-
run: cargo xtask publish-stage --target all --profile release
129+
- name: Stage native artifacts
130+
run: cargo xtask publish-stage --target all --profile release --native-only
127131

128-
- name: Upload publish folder
132+
- name: Upload staged native assets
129133
uses: actions/upload-artifact@v4
130134
with:
131-
name: publish-macos
132-
path: publish/
135+
name: stage-macos
136+
path: |
137+
publish/native/
138+
packages/webui-darwin-arm64/
139+
packages/webui-darwin-x64/
140+
dotnet/runtimes/osx-arm64/
141+
dotnet/runtimes/osx-x64/
133142
retention-days: 1
134143

135144
build-windows:
@@ -143,7 +152,6 @@ jobs:
143152
with:
144153
shared-cache-key: publish-windows
145154
rust-targets: x86_64-pc-windows-msvc, aarch64-pc-windows-msvc
146-
dotnet: '8.0.x'
147155
skip-build: 'true'
148156

149157
- name: Build x64 (native)
@@ -162,17 +170,22 @@ jobs:
162170
-p microsoft-webui-ffi
163171
-p microsoft-webui-node
164172
165-
- name: Stage all artifacts
166-
run: cargo xtask publish-stage --target all --profile release
173+
- name: Stage native artifacts
174+
run: cargo xtask publish-stage --target all --profile release --native-only
167175

168-
- name: Upload publish folder
176+
- name: Upload staged native assets
169177
uses: actions/upload-artifact@v4
170178
with:
171-
name: publish-windows
172-
path: publish/
179+
name: stage-windows
180+
path: |
181+
publish/native/
182+
packages/webui-win32-x64/
183+
packages/webui-win32-arm64/
184+
dotnet/runtimes/win-x64/
185+
dotnet/runtimes/win-arm64/
173186
retention-days: 1
174187

175-
# ── Step 3: Merge artifacts, tag, and create release ──────────────────
188+
# ── Step 3: Merge native assets, pack once, tag, and create release ───
176189
release:
177190
name: Create Release
178191
needs: [check-version, build-linux, build-macos, build-windows]
@@ -182,14 +195,35 @@ jobs:
182195
with:
183196
fetch-depth: 0
184197

185-
# Download and merge all publish/ folders from the 3 runners
186-
- name: Download all publish artifacts
198+
- uses: ./.github/actions/build
199+
with:
200+
shared-cache-key: publish-release
201+
dotnet: '8.0.x'
202+
skip-build: 'true'
203+
204+
# Download and merge all staged native assets from the 3 runners
205+
- name: Download staged native artifacts
187206
uses: actions/download-artifact@v4
188207
with:
189-
pattern: publish-*
190-
path: publish/
208+
pattern: stage-*
209+
path: .
191210
merge-multiple: true
192211

212+
- name: Setup WASM C headers
213+
shell: bash
214+
run: |
215+
cargo fetch
216+
WASM_HEADERS=$(find $HOME/.cargo/registry/src -path "*/tree-sitter-language-*/wasm/include" -type d | head -1)
217+
if [ -n "$WASM_HEADERS" ]; then
218+
echo "WASI_INCLUDE=$WASM_HEADERS" >> $GITHUB_ENV
219+
else
220+
echo "::error::Could not find tree-sitter-language WASM headers after cargo fetch"
221+
exit 1
222+
fi
223+
224+
- name: Pack unified release artifacts
225+
run: cargo xtask publish-stage --pack-only --profile release
226+
193227
# List all artifacts for verification
194228
- name: List publish artifacts
195229
run: find publish/ -type f | sort

README.md

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ All development tasks go through `cargo xtask`:
4747
| `cargo xtask bench <crate>` | Run benchmarks (parser, handler, protocol, expressions, state, all) |
4848
| `cargo xtask dev <app>` | Run example app in dev mode |
4949
| `cargo xtask version <semver>` | Update version across all Cargo.toml and package.json files |
50-
| `cargo xtask publish-stage` | Stage all release artifacts into `publish/` (npm, NuGet, crates, WASM, native binaries) |
50+
| `cargo xtask publish-stage` | Stage release artifacts into `publish/` (supports `--native-only` and `--pack-only`) |
5151

5252
### CI Pipelines
5353

@@ -91,7 +91,7 @@ graph LR
9191
buildL["Build Linux<br/><small>x64 + arm64 (cross)</small>"]
9292
buildM["Build macOS<br/><small>arm64 + x64 (cross)</small>"]
9393
buildW["Build Windows<br/><small>x64 + arm64 (cross)</small>"]
94-
release["Release<br/><small>merge → tag → GitHub Release</small>"]
94+
release["Release<br/><small>merge staged natives → pack → tag → GitHub Release</small>"]
9595
9696
ver --> buildL
9797
ver --> buildM
@@ -101,7 +101,14 @@ graph LR
101101
buildW --> release
102102
```
103103

104-
Each build runner produces a complete `publish/` folder containing:
104+
Each build runner uploads only the platform-native inputs it produced:
105+
106+
- `publish/native/` direct-download CLI binaries
107+
- `packages/webui-*` directories populated with the platform CLI + Node addon
108+
- `dotnet/runtimes/*` directories populated with the platform FFI library
109+
110+
The release job merges those staged files and then runs `cargo xtask publish-stage --pack-only`
111+
once on Linux to build the final `publish/` folder:
105112

106113
| Subfolder | Contents | Target registry |
107114
|-----------|----------|-----------------|

xtask/src/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ fn usage() -> ExitCode {
115115
e2e [--update-snapshots] Run Playwright E2E tests for all example apps\n \
116116
e2e-approve [run-id] Download CI screenshot baselines and apply locally\n \
117117
version <semver> Update version across all Cargo.toml and package.json files\n \
118-
publish-stage [--target <triple|all>] [--profile release] Stage all release artifacts into publish/\n \
118+
publish-stage [--target <triple|all>] [--profile release] [--native-only|--pack-only] Stage release artifacts into publish/\n \
119119
license-headers [--fix] Check (or fix) license headers in source files"
120120
);
121121
ExitCode::SUCCESS

0 commit comments

Comments
 (0)