Skip to content

Commit 59344cb

Browse files
chore: Fix builds (#5)
1 parent 4497a9a commit 59344cb

File tree

33 files changed

+436
-213
lines changed

33 files changed

+436
-213
lines changed

.github/workflows/CI.yml

Lines changed: 110 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ jobs:
7878
shell: bash
7979

8080
- name: Build
81-
run: npx nx build:native -- --target ${{ matrix.target }}
81+
run: npx nx run @kevinmichaelchen/cel-typescript-core:build:native --target=${{ matrix.target }}
8282
env:
8383
USE_ZIG: ${{ runner.os == 'Linux' }}
8484
shell: bash
@@ -129,10 +129,22 @@ jobs:
129129
node-version: 18
130130
cache: npm
131131

132-
- name: Download artifacts
132+
- name: Download all artifacts
133133
uses: actions/download-artifact@v4
134134
with:
135-
name: bindings-${{ matrix.target }}
135+
pattern: bindings-*
136+
merge-multiple: true
137+
138+
- name: Copy binaries to src for testing
139+
run: |
140+
# Copy all .node files found in libs/core to libs/core/src
141+
echo "Copying all .node binaries to libs/core/src/"
142+
find "libs/core" -maxdepth 1 -name "*.node" -exec cp {} "libs/core/src/" \;
143+
144+
# Show what was copied
145+
echo "Files in libs/core/src:"
146+
find "libs/core/src" -type f -name "*.node" | sort
147+
shell: bash
136148

137149
- name: Install dependencies
138150
run: npm install
@@ -174,42 +186,116 @@ jobs:
174186
pattern: bindings-*
175187
merge-multiple: true
176188

177-
- name: Move artifacts
189+
- name: Process artifacts and prepare packages
178190
run: |
179191
echo "Debug: Showing all downloaded artifacts:"
180192
find . -type f -name "*.node" -ls
181193
182-
echo "\nMoving only cel-typescript binaries to root:"
183-
find . -type f -name "cel-typescript.*.node" -exec mv {} . \;
184-
185-
echo "\nBinaries in root directory:"
186-
ls -la cel-typescript.*.node
187-
188-
# Count our binaries
189-
node_count=$(ls -1 cel-typescript.*.node 2>/dev/null | wc -l)
190-
expected_count=5 # We target 5 platforms
191-
192-
echo "\nFound $node_count cel-typescript binaries (expected $expected_count)"
194+
echo "\nEnsuring binaries exist in their respective package directories:"
195+
196+
# Make sure each package directory has exactly one binary
197+
# Copy only if not already present in the target directory
198+
if [ ! -f libs/darwin-arm64/cel-typescript.darwin-arm64.node ]; then
199+
find . -path "./libs/darwin-arm64" -prune -o -name "cel-typescript.darwin-arm64.node" -exec cp {} libs/darwin-arm64/ \;
200+
fi
201+
202+
if [ ! -f libs/darwin-x64/cel-typescript.darwin-x64.node ]; then
203+
find . -path "./libs/darwin-x64" -prune -o -name "cel-typescript.darwin-x64.node" -exec cp {} libs/darwin-x64/ \;
204+
fi
205+
206+
if [ ! -f libs/linux-x64-gnu/cel-typescript.linux-x64-gnu.node ]; then
207+
find . -path "./libs/linux-x64-gnu" -prune -o -name "cel-typescript.linux-x64-gnu.node" -exec cp {} libs/linux-x64-gnu/ \;
208+
fi
209+
210+
if [ ! -f libs/linux-arm64-gnu/cel-typescript.linux-arm64-gnu.node ]; then
211+
find . -path "./libs/linux-arm64-gnu" -prune -o -name "cel-typescript.linux-arm64-gnu.node" -exec cp {} libs/linux-arm64-gnu/ \;
212+
fi
213+
214+
if [ ! -f libs/win32-x64-msvc/cel-typescript.win32-x64-msvc.node ]; then
215+
find . -path "./libs/win32-x64-msvc" -prune -o -name "cel-typescript.win32-x64-msvc.node" -exec cp {} libs/win32-x64-msvc/ \;
216+
fi
217+
218+
# Verify each package directory has exactly one binary
219+
darwin_arm64_count=$(find libs/darwin-arm64 -maxdepth 1 -name "cel-typescript.darwin-arm64.node" | wc -l)
220+
darwin_x64_count=$(find libs/darwin-x64 -maxdepth 1 -name "cel-typescript.darwin-x64.node" | wc -l)
221+
linux_x64_gnu_count=$(find libs/linux-x64-gnu -maxdepth 1 -name "cel-typescript.linux-x64-gnu.node" | wc -l)
222+
linux_arm64_gnu_count=$(find libs/linux-arm64-gnu -maxdepth 1 -name "cel-typescript.linux-arm64-gnu.node" | wc -l)
223+
win32_x64_msvc_count=$(find libs/win32-x64-msvc -maxdepth 1 -name "cel-typescript.win32-x64-msvc.node" | wc -l)
224+
225+
echo "\nVerifying binaries in package directories:"
226+
echo "darwin-arm64: $darwin_arm64_count"
227+
echo "darwin-x64: $darwin_x64_count"
228+
echo "linux-x64-gnu: $linux_x64_gnu_count"
229+
echo "linux-arm64-gnu: $linux_arm64_gnu_count"
230+
echo "win32-x64-msvc: $win32_x64_msvc_count"
193231
194-
if [ "$node_count" -ne "$expected_count" ]; then
195-
echo "Error: Expected $expected_count binaries but found $node_count"
232+
# Error if any platform is missing its binary
233+
if [ "$darwin_arm64_count" -ne 1 ] || [ "$darwin_x64_count" -ne 1 ] || \
234+
[ "$linux_x64_gnu_count" -ne 1 ] || [ "$linux_arm64_gnu_count" -ne 1 ] || \
235+
[ "$win32_x64_msvc_count" -ne 1 ]; then
236+
echo "Error: Each package directory should have exactly one binary"
196237
exit 1
197238
fi
239+
240+
# Set version for all packages based on tag
241+
if [[ "$GITHUB_REF" == refs/tags/v* ]]; then
242+
VERSION=${GITHUB_REF#refs/tags/v}
243+
echo "Setting version to $VERSION for all packages"
244+
245+
for pkg in libs/darwin-arm64 libs/darwin-x64 libs/linux-x64-gnu libs/linux-arm64-gnu libs/win32-x64-msvc; do
246+
jq ".version = \"$VERSION\"" $pkg/package.json > tmp.json && mv tmp.json $pkg/package.json
247+
done
248+
249+
# Set the core package version too
250+
jq ".version = \"$VERSION\"" libs/core/package.json > tmp.json && mv tmp.json libs/core/package.json
251+
252+
# Update the optionalDependencies in the core package to use version numbers instead of file paths
253+
node -e "const pkg = require('./libs/core/package.json'); \
254+
if (pkg.optionalDependencies) { \
255+
Object.keys(pkg.optionalDependencies).forEach(dep => { \
256+
pkg.optionalDependencies[dep] = '$VERSION'; \
257+
}); \
258+
require('fs').writeFileSync('./libs/core/package.json', JSON.stringify(pkg, null, 2)); \
259+
}"
260+
else
261+
echo "Not a tag push, skipping version update"
262+
fi
198263
199264
- name: Build TypeScript
200265
run: npm run build:ts
201266

202-
- name: Verify package contents
267+
- name: Publish Core Package (Dry Run)
268+
if: github.event_name == 'pull_request'
203269
run: |
204-
echo "Package contents:"
270+
cd libs/core
205271
npm pack --dry-run
206272
207-
- name: Publish
273+
- name: Publish Platform Packages (Dry Run)
274+
if: github.event_name == 'pull_request'
275+
run: |
276+
for pkg in darwin-arm64 darwin-x64 linux-x64-gnu linux-arm64-gnu win32-x64-msvc; do
277+
echo "\n==== Dry run publishing $pkg package ===="
278+
cd libs/$pkg
279+
npm pack --dry-run
280+
cd ../..
281+
done
282+
283+
- name: Publish Core Package
208284
if: startsWith(github.ref, 'refs/tags/v')
209-
run: npm publish --provenance --access public
285+
run: |
286+
cd libs/core
287+
npm publish --provenance --access public
210288
env:
211289
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
212290

213-
- name: Publish (Dry Run)
214-
if: github.event_name == 'pull_request'
215-
run: npm publish --dry-run
291+
- name: Publish Platform Packages
292+
if: startsWith(github.ref, 'refs/tags/v')
293+
run: |
294+
for pkg in darwin-arm64 darwin-x64 linux-x64-gnu linux-arm64-gnu win32-x64-msvc; do
295+
echo "\n==== Publishing $pkg package ===="
296+
cd libs/$pkg
297+
npm publish --provenance --access public
298+
cd ../..
299+
done
300+
env:
301+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

.gitignore

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# Rust
2-
/target
2+
libs/core/target
3+
34
**/*.rs.bk
45
Cargo.lock
56

@@ -37,3 +38,6 @@ coverage/
3738
.env
3839
.env.local
3940
.env.*.local
41+
42+
# Tarballs from testing with `npm pack`
43+
*.tgz

.gitmodules

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
[submodule "cel-rust"]
2-
path = cel-rust
1+
[submodule "libs/core/cel-rust"]
2+
path = libs/core/cel-rust
33
url = https://github.com/clarkmcc/cel-rust.git

.husky/pre-commit

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1 @@
1-
npx nx run cel-typescript:format:check
2-
npx nx run cel-typescript:check
3-
npx nx run cel-typescript:lint
1+
npm run format

biome.json

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,19 @@
55
},
66
"files": {
77
"include": ["**/*.ts", "**/*.tsx", "**/*.js", "**/*.jsx", "**/*.json"],
8-
"ignore": [".nx", "index.js", "index.d.ts", "dist/**/*"]
8+
"ignore": [
9+
".nx",
10+
"**/dist/**/*",
11+
"**/target/**",
12+
"**/artifacts/native.d.ts",
13+
"**/native.d.ts"
14+
]
915
},
1016
"formatter": {
1117
"enabled": true,
1218
"indentStyle": "space",
1319
"indentWidth": 2,
14-
"lineWidth": 80,
15-
"ignore": ["index.js"]
20+
"lineWidth": 80
1621
},
1722
"linter": {
1823
"enabled": true,

cel-rust

Lines changed: 0 additions & 1 deletion
This file was deleted.

esm/wrapper.js

Lines changed: 0 additions & 4 deletions
This file was deleted.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)