Skip to content

Commit a661725

Browse files
committed
feat(native): include static builds
1 parent 85afc2b commit a661725

File tree

3 files changed

+122
-35
lines changed

3 files changed

+122
-35
lines changed

.github/workflows/build-native.yml

Lines changed: 100 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -59,21 +59,22 @@ jobs:
5959
# Verify critical files exist (all 6 platforms)
6060
echo ""
6161
echo "Verifying native binaries exist..."
62-
test -f packages/core/node_modules/@opentui/core-darwin-x64/libopentui.dylib || (echo "❌ darwin-x64 binary missing!" && exit 1)
63-
test -f packages/core/node_modules/@opentui/core-darwin-arm64/libopentui.dylib || (echo "❌ darwin-arm64 binary missing!" && exit 1)
64-
test -f packages/core/node_modules/@opentui/core-linux-x64/libopentui.so || (echo "❌ linux-x64 binary missing!" && exit 1)
65-
test -f packages/core/node_modules/@opentui/core-linux-arm64/libopentui.so || (echo "❌ linux-arm64 binary missing!" && exit 1)
66-
test -f packages/core/node_modules/@opentui/core-win32-x64/opentui.dll || (echo "❌ windows-x64 binary missing!" && exit 1)
67-
test -f packages/core/node_modules/@opentui/core-win32-arm64/opentui.dll || (echo "❌ windows-arm64 binary missing!" && exit 1)
68-
69-
echo "Verifying dist packages exist..."
70-
test -d packages/core/dist || (echo "❌ core dist missing!" && exit 1)
71-
test -f packages/core/dist/package.json || (echo "❌ core dist/package.json missing!" && exit 1)
62+
test -f packages/core/node_modules/@opentui/core-darwin-x64/libopentui.dylib || (echo "❌ darwin-x64 dynamic binary missing!" && exit 1)
63+
test -f packages/core/node_modules/@opentui/core-darwin-x64/libopentui.a || (echo "❌ darwin-x64 static binary missing!" && exit 1)
64+
test -f packages/core/node_modules/@opentui/core-darwin-arm64/libopentui.dylib || (echo "❌ darwin-arm64 dynamic binary missing!" && exit 1)
65+
test -f packages/core/node_modules/@opentui/core-darwin-arm64/libopentui.a || (echo "❌ darwin-arm64 static binary missing!" && exit 1)
66+
test -f packages/core/node_modules/@opentui/core-linux-x64/libopentui.so || (echo "❌ linux-x64 dynamic binary missing!" && exit 1)
67+
test -f packages/core/node_modules/@opentui/core-linux-x64/libopentui.a || (echo "❌ linux-x64 static binary missing!" && exit 1)
68+
test -f packages/core/node_modules/@opentui/core-linux-arm64/libopentui.so || (echo "❌ linux-arm64 dynamic binary missing!" && exit 1)
69+
test -f packages/core/node_modules/@opentui/core-linux-arm64/libopentui.a || (echo "❌ linux-arm64 static binary missing!" && exit 1)
70+
test -f packages/core/node_modules/@opentui/core-win32-x64/opentui.dll || (echo "❌ windows-x64 dynamic binary missing!" && exit 1)
71+
test -f packages/core/node_modules/@opentui/core-win32-x64/opentui.lib || (echo "❌ windows-x64 static binary missing!" && exit 1)
72+
test -f packages/core/node_modules/@opentui/core-win32-arm64/opentui.dll || (echo "❌ windows-arm64 dynamic binary missing!" && exit 1)
73+
test -f packages/core/node_modules/@opentui/core-win32-arm64/opentui.lib || (echo "❌ windows-arm64 static binary missing!" && exit 1)
7274
7375
echo "✅ All required build outputs verified (6 platforms)"
7476
75-
# Create separate zips for each platform's native binaries
76-
- name: Package native binaries - darwin-x64
77+
- name: Package dynamic binaries - darwin-x64
7778
run: |
7879
set -e
7980
mkdir -p artifacts/native-darwin-x64
@@ -82,9 +83,8 @@ jobs:
8283
zip -r native-darwin-x64.zip native-darwin-x64/
8384
test -f native-darwin-x64.zip || (echo "❌ Failed to create darwin-x64 zip" && exit 1)
8485
test -s native-darwin-x64.zip || (echo "❌ darwin-x64 zip is empty" && exit 1)
85-
echo "✅ darwin-x64 packaged successfully ($(du -h native-darwin-x64.zip | cut -f1))"
86-
87-
- name: Package native binaries - darwin-arm64
86+
echo "✅ darwin-x64 dynamic packaged successfully ($(du -h native-darwin-x64.zip | cut -f1))"
87+
- name: Package dynamic binaries - darwin-arm64
8888
run: |
8989
set -e
9090
mkdir -p artifacts/native-darwin-arm64
@@ -93,9 +93,8 @@ jobs:
9393
zip -r native-darwin-arm64.zip native-darwin-arm64/
9494
test -f native-darwin-arm64.zip || (echo "❌ Failed to create darwin-arm64 zip" && exit 1)
9595
test -s native-darwin-arm64.zip || (echo "❌ darwin-arm64 zip is empty" && exit 1)
96-
echo "✅ darwin-arm64 packaged successfully ($(du -h native-darwin-arm64.zip | cut -f1))"
97-
98-
- name: Package native binaries - linux-x64
96+
echo "✅ darwin-arm64 dynamic packaged successfully ($(du -h native-darwin-arm64.zip | cut -f1))"
97+
- name: Package dynamic binaries - linux-x64
9998
run: |
10099
set -e
101100
mkdir -p artifacts/native-linux-x64
@@ -104,9 +103,8 @@ jobs:
104103
zip -r native-linux-x64.zip native-linux-x64/
105104
test -f native-linux-x64.zip || (echo "❌ Failed to create linux-x64 zip" && exit 1)
106105
test -s native-linux-x64.zip || (echo "❌ linux-x64 zip is empty" && exit 1)
107-
echo "✅ linux-x64 packaged successfully ($(du -h native-linux-x64.zip | cut -f1))"
108-
109-
- name: Package native binaries - windows-x64
106+
echo "✅ linux-x64 dynamic packaged successfully ($(du -h native-linux-x64.zip | cut -f1))"
107+
- name: Package dynamic binaries - windows-x64
110108
run: |
111109
set -e
112110
mkdir -p artifacts/native-windows-x64
@@ -115,9 +113,8 @@ jobs:
115113
zip -r native-windows-x64.zip native-windows-x64/
116114
test -f native-windows-x64.zip || (echo "❌ Failed to create windows-x64 zip" && exit 1)
117115
test -s native-windows-x64.zip || (echo "❌ windows-x64 zip is empty" && exit 1)
118-
echo "✅ windows-x64 packaged successfully ($(du -h native-windows-x64.zip | cut -f1))"
119-
120-
- name: Package native binaries - linux-arm64
116+
echo "✅ windows-x64 dynamic packaged successfully ($(du -h native-windows-x64.zip | cut -f1))"
117+
- name: Package dynamic binaries - linux-arm64
121118
run: |
122119
set -e
123120
mkdir -p artifacts/native-linux-arm64
@@ -126,9 +123,8 @@ jobs:
126123
zip -r native-linux-arm64.zip native-linux-arm64/
127124
test -f native-linux-arm64.zip || (echo "❌ Failed to create linux-arm64 zip" && exit 1)
128125
test -s native-linux-arm64.zip || (echo "❌ linux-arm64 zip is empty" && exit 1)
129-
echo "✅ linux-arm64 packaged successfully ($(du -h native-linux-arm64.zip | cut -f1))"
130-
131-
- name: Package native binaries - windows-arm64
126+
echo "✅ linux-arm64 dynamic packaged successfully ($(du -h native-linux-arm64.zip | cut -f1))"
127+
- name: Package dynamic binaries - windows-arm64
132128
run: |
133129
set -e
134130
mkdir -p artifacts/native-windows-arm64
@@ -137,7 +133,68 @@ jobs:
137133
zip -r native-windows-arm64.zip native-windows-arm64/
138134
test -f native-windows-arm64.zip || (echo "❌ Failed to create windows-arm64 zip" && exit 1)
139135
test -s native-windows-arm64.zip || (echo "❌ windows-arm64 zip is empty" && exit 1)
140-
echo "✅ windows-arm64 packaged successfully ($(du -h native-windows-arm64.zip | cut -f1))"
136+
echo "✅ windows-arm64 dynamic packaged successfully ($(du -h native-windows-arm64.zip | cut -f1))"
137+
138+
- name: Package static binaries - darwin-x64
139+
run: |
140+
set -e
141+
mkdir -p artifacts/native-darwin-x64-static
142+
cp packages/core/node_modules/@opentui/core-darwin-x64/libopentui.a artifacts/native-darwin-x64-static/
143+
cd artifacts
144+
zip -r native-darwin-x64-static.zip native-darwin-x64-static/
145+
test -f native-darwin-x64-static.zip || (echo "❌ Failed to create darwin-x64-static zip" && exit 1)
146+
test -s native-darwin-x64-static.zip || (echo "❌ darwin-x64-static zip is empty" && exit 1)
147+
echo "✅ darwin-x64 static packaged successfully ($(du -h native-darwin-x64-static.zip | cut -f1))"
148+
- name: Package static binaries - darwin-arm64
149+
run: |
150+
set -e
151+
mkdir -p artifacts/native-darwin-arm64-static
152+
cp packages/core/node_modules/@opentui/core-darwin-arm64/libopentui.a artifacts/native-darwin-arm64-static/
153+
cd artifacts
154+
zip -r native-darwin-arm64-static.zip native-darwin-arm64-static/
155+
test -f native-darwin-arm64-static.zip || (echo "❌ Failed to create darwin-arm64-static zip" && exit 1)
156+
test -s native-darwin-arm64-static.zip || (echo "❌ darwin-arm64-static zip is empty" && exit 1)
157+
echo "✅ darwin-arm64 static packaged successfully ($(du -h native-darwin-arm64-static.zip | cut -f1))"
158+
- name: Package static binaries - linux-x64
159+
run: |
160+
set -e
161+
mkdir -p artifacts/native-linux-x64-static
162+
cp packages/core/node_modules/@opentui/core-linux-x64/libopentui.a artifacts/native-linux-x64-static/
163+
cd artifacts
164+
zip -r native-linux-x64-static.zip native-linux-x64-static/
165+
test -f native-linux-x64-static.zip || (echo "❌ Failed to create linux-x64-static zip" && exit 1)
166+
test -s native-linux-x64-static.zip || (echo "❌ linux-x64-static zip is empty" && exit 1)
167+
echo "✅ linux-x64 static packaged successfully ($(du -h native-linux-x64-static.zip | cut -f1))"
168+
- name: Package static binaries - windows-x64
169+
run: |
170+
set -e
171+
mkdir -p artifacts/native-windows-x64-static
172+
cp packages/core/node_modules/@opentui/core-win32-x64/opentui.lib artifacts/native-windows-x64-static/
173+
cd artifacts
174+
zip -r native-windows-x64-static.zip native-windows-x64-static/
175+
test -f native-windows-x64-static.zip || (echo "❌ Failed to create windows-x64-static zip" && exit 1)
176+
test -s native-windows-x64-static.zip || (echo "❌ windows-x64-static zip is empty" && exit 1)
177+
echo "✅ windows-x64 static packaged successfully ($(du -h native-windows-x64-static.zip | cut -f1))"
178+
- name: Package static binaries - linux-arm64
179+
run: |
180+
set -e
181+
mkdir -p artifacts/native-linux-arm64-static
182+
cp packages/core/node_modules/@opentui/core-linux-arm64/libopentui.a artifacts/native-linux-arm64-static/
183+
cd artifacts
184+
zip -r native-linux-arm64-static.zip native-linux-arm64-static/
185+
test -f native-linux-arm64-static.zip || (echo "❌ Failed to create linux-arm64-static zip" && exit 1)
186+
test -s native-linux-arm64-static.zip || (echo "❌ linux-arm64-static zip is empty" && exit 1)
187+
echo "✅ linux-arm64 static packaged successfully ($(du -h native-linux-arm64-static.zip | cut -f1))"
188+
- name: Package static binaries - windows-arm64
189+
run: |
190+
set -e
191+
mkdir -p artifacts/native-windows-arm64-static
192+
cp packages/core/node_modules/@opentui/core-win32-arm64/opentui.lib artifacts/native-windows-arm64-static/
193+
cd artifacts
194+
zip -r native-windows-arm64-static.zip native-windows-arm64-static/
195+
test -f native-windows-arm64-static.zip || (echo "❌ Failed to create windows-arm64-static zip" && exit 1)
196+
test -s native-windows-arm64-static.zip || (echo "❌ windows-arm64-static zip is empty" && exit 1)
197+
echo "✅ windows-arm64 static packaged successfully ($(du -h native-windows-arm64-static.zip | cut -f1))"
141198
142199
# Package the built npm packages (for use by build-examples and npm-publish)
143200
- name: Package npm packages
@@ -179,16 +236,24 @@ jobs:
179236
run: |
180237
set -e
181238
echo "Verifying all artifacts exist..."
239+
# Dynamic libraries
182240
test -f artifacts/native-darwin-x64.zip || (echo "❌ native-darwin-x64.zip missing!" && exit 1)
183241
test -f artifacts/native-darwin-arm64.zip || (echo "❌ native-darwin-arm64.zip missing!" && exit 1)
184242
test -f artifacts/native-linux-x64.zip || (echo "❌ native-linux-x64.zip missing!" && exit 1)
185243
test -f artifacts/native-linux-arm64.zip || (echo "❌ native-linux-arm64.zip missing!" && exit 1)
186244
test -f artifacts/native-windows-x64.zip || (echo "❌ native-windows-x64.zip missing!" && exit 1)
187245
test -f artifacts/native-windows-arm64.zip || (echo "❌ native-windows-arm64.zip missing!" && exit 1)
246+
# Static libraries
247+
test -f artifacts/native-darwin-x64-static.zip || (echo "❌ native-darwin-x64-static.zip missing!" && exit 1)
248+
test -f artifacts/native-darwin-arm64-static.zip || (echo "❌ native-darwin-arm64-static.zip missing!" && exit 1)
249+
test -f artifacts/native-linux-x64-static.zip || (echo "❌ native-linux-x64-static.zip missing!" && exit 1)
250+
test -f artifacts/native-linux-arm64-static.zip || (echo "❌ native-linux-arm64-static.zip missing!" && exit 1)
251+
test -f artifacts/native-windows-x64-static.zip || (echo "❌ native-windows-x64-static.zip missing!" && exit 1)
252+
test -f artifacts/native-windows-arm64-static.zip || (echo "❌ native-windows-arm64-static.zip missing!" && exit 1)
188253
test -f artifacts/npm-packages.zip || (echo "❌ npm-packages.zip missing!" && exit 1)
189254
190255
echo ""
191-
echo "✅ All 6 platform artifacts verified. Ready to upload:"
256+
echo "✅ All 12 artifacts verified. Ready to upload:"
192257
ls -lah artifacts/*.zip
193258
194259
- name: Upload native binaries artifacts
@@ -202,6 +267,12 @@ jobs:
202267
artifacts/native-linux-arm64.zip
203268
artifacts/native-windows-x64.zip
204269
artifacts/native-windows-arm64.zip
270+
artifacts/native-darwin-x64-static.zip
271+
artifacts/native-darwin-arm64-static.zip
272+
artifacts/native-linux-x64-static.zip
273+
artifacts/native-linux-arm64-static.zip
274+
artifacts/native-windows-x64-static.zip
275+
artifacts/native-windows-arm64-static.zip
205276
if-no-files-found: error
206277
retention-days: 30
207278

.github/workflows/release.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ jobs:
211211
# Verify all expected release assets exist
212212
echo ""
213213
echo "Verifying all release assets..."
214-
EXPECTED_ASSETS=10 # 6 native (darwin-x64, darwin-arm64, linux-x64, linux-arm64, windows-x64, windows-arm64) + 4 examples (no linux-arm64, no windows-arm64)
214+
EXPECTED_ASSETS=16 # 12 native (one dyn & one static for each: darwin-x64, darwin-arm64, linux-x64, linux-arm64, windows-x64, windows-arm64) + 4 examples (no linux-arm64, no windows-arm64)
215215
ACTUAL_ASSETS=$(ls -1 release-assets/*.zip 2>/dev/null | wc -l | tr -d ' ')
216216
217217
if [ "$ACTUAL_ASSETS" -ne "$EXPECTED_ASSETS" ]; then
@@ -221,7 +221,7 @@ jobs:
221221
fi
222222
223223
echo "✅ All $ACTUAL_ASSETS release assets prepared:"
224-
echo " - 6 native binaries (all platforms)"
224+
echo " - 12 native binaries (all platforms)"
225225
echo " - 4 example executables (darwin-x64, darwin-arm64, linux-x64, windows-x64)"
226226
ls -lah release-assets/
227227

packages/core/src/zig/build.zig

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -267,13 +267,27 @@ fn buildTarget(
267267

268268
applyDependencies(b, module, optimize, target, build_options);
269269

270-
const lib = b.addLibrary(.{
270+
// Build dynamic library
271+
const dyn_lib = b.addLibrary(.{
271272
.name = LIB_NAME,
272273
.root_module = module,
273274
.linkage = .dynamic,
274275
});
276+
const dyn_install_dir = b.addInstallArtifact(dyn_lib, .{
277+
.dest_dir = .{
278+
.override = .{
279+
.custom = try std.fmt.allocPrint(b.allocator, "../lib/{s}", .{output_name}),
280+
},
281+
},
282+
});
275283

276-
const install_dir = b.addInstallArtifact(lib, .{
284+
// Build static library
285+
const static_lib = b.addLibrary(.{
286+
.name = LIB_NAME,
287+
.root_module = module,
288+
.linkage = .static,
289+
});
290+
const static_install_dir = b.addInstallArtifact(static_lib, .{
277291
.dest_dir = .{
278292
.override = .{
279293
.custom = try std.fmt.allocPrint(b.allocator, "../lib/{s}", .{output_name}),
@@ -283,7 +297,9 @@ fn buildTarget(
283297

284298
const build_step_name = try std.fmt.allocPrint(b.allocator, "build-{s}", .{output_name});
285299
const build_step = b.step(build_step_name, try std.fmt.allocPrint(b.allocator, "Build for {s}", .{description}));
286-
build_step.dependOn(&install_dir.step);
300+
build_step.dependOn(&dyn_install_dir.step);
301+
build_step.dependOn(&static_install_dir.step);
287302

288-
b.getInstallStep().dependOn(&install_dir.step);
303+
b.getInstallStep().dependOn(&dyn_install_dir.step);
304+
b.getInstallStep().dependOn(&static_install_dir.step);
289305
}

0 commit comments

Comments
 (0)