Skip to content

Commit b766847

Browse files
RoyLinRoyLin
authored andcommitted
ci(publish-ts): publish one bundled package with all .node binaries
The napi multi-package flow (create-npm-dir/artifacts/prepublish) is broken/fiddly in this CLI version (create-npm-dir errors, prepublish needs pre-existing npm/ dirs). Pivot: bundle all 3 platform .node into the single main package; the generated index.js loads the right one per platform via its local-file fallback (verified). files now includes *.node.
1 parent 8d12589 commit b766847

2 files changed

Lines changed: 14 additions & 10 deletions

File tree

.github/workflows/publish-ts.yml

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
name: publish-ts
22

33
# Publish the native napi SDK (@a3s-lab/sentry) to npm on a `ts-vX.Y.Z` tag. Builds the native addon
4-
# per platform, then publishes the main package + per-platform binaries (the napi-rs convention).
5-
# Requires an `NPM_TOKEN` secret. (The per-platform sub-packages live under the @a3s-lab npm scope.)
4+
# per platform, then publishes ONE package bundling all the .node binaries the generated index.js
5+
# loads the right one per platform (its built-in local-file fallback). Requires an `NPM_TOKEN` secret.
66
on:
77
push:
88
tags: ["ts-v*"]
@@ -36,17 +36,17 @@ jobs:
3636
- run: npm run build -- --target ${{ matrix.settings.target }}
3737
- run: npm test
3838
if: runner.os != 'Windows' # the suite uses a unix mock-agent .sh + unix-absolute paths
39-
4039
- uses: actions/upload-artifact@v4
4140
with:
4241
name: bindings-${{ matrix.settings.target }}
43-
path: sdk/typescript/*.node
42+
path: |
43+
sdk/typescript/*.node
44+
sdk/typescript/index.js
45+
sdk/typescript/index.d.ts
4446
4547
publish:
4648
needs: build
4749
runs-on: ubuntu-latest
48-
# NODE_AUTH_TOKEN applies to ALL steps: `napi prepublish` publishes the per-platform packages and
49-
# `npm publish` the main one — both need the token.
5050
env:
5151
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
5252
steps:
@@ -56,10 +56,13 @@ jobs:
5656
with:
5757
node-version: "20"
5858
registry-url: "https://registry.npmjs.org"
59-
- run: npm install
6059
- uses: actions/download-artifact@v4
6160
with:
6261
path: sdk/typescript/artifacts
63-
- run: npx napi artifacts --dir artifacts
64-
- run: npx napi prepublish -t npm
62+
- name: Bundle all platform binaries + the generated glue into the package
63+
run: |
64+
cp artifacts/*/*.node .
65+
cp artifacts/bindings-x86_64-unknown-linux-gnu/index.js .
66+
cp artifacts/bindings-x86_64-unknown-linux-gnu/index.d.ts .
67+
echo "--- package will ship ---" && ls -lh *.node index.js index.d.ts
6568
- run: npm publish --access public

sdk/typescript/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@
2222
},
2323
"files": [
2424
"index.js",
25-
"index.d.ts"
25+
"index.d.ts",
26+
"*.node"
2627
],
2728
"engines": {
2829
"node": ">=12"

0 commit comments

Comments
 (0)