@@ -3,14 +3,28 @@ name: Publish Node SDK
33on :
44 release :
55 types : [published]
6+ workflow_dispatch :
7+ inputs :
8+ version :
9+ description : ' Version to publish (without leading v, e.g. 1.9.1)'
10+ required : true
11+ type : string
12+ prerelease :
13+ description : ' Treat as prerelease (skip publish; build only)'
14+ required : false
15+ type : boolean
16+ default : false
617
718permissions :
819 contents : write
920 id-token : write
1021
22+ env :
23+ PILOT_VERSION : ${{ inputs.version || github.event.release.tag_name }}
24+ PILOT_PRERELEASE : ${{ inputs.prerelease || github.event.release.prerelease }}
25+
1126jobs :
1227 test-sdk :
13- if : " !github.event.release.prerelease"
1428 runs-on : ubuntu-latest
1529 defaults :
1630 run :
@@ -38,10 +52,10 @@ jobs:
3852 - name : Checkout repository
3953 uses : actions/checkout@v4
4054
41- - name : Set version from release tag
55+ - name : Set version from release tag or workflow input
4256 shell : bash
4357 run : |
44- VERSION="${{ github.event.release.tag_name } }"
58+ VERSION="${PILOT_VERSION }"
4559 VERSION="${VERSION#v}"
4660 echo "version=$VERSION" >> $GITHUB_ENV
4761 cd sdk/node
@@ -82,25 +96,63 @@ jobs:
8296 echo "Package contents:"
8397 npm pack --dry-run
8498 echo ""
85- echo "Binary sizes :"
99+ echo "Built binary subdirs :"
86100 ls -lh bin/
87101
88- - name : Upload package artifact
102+ # Upload only the platform-specific binary subdir; the publish job
103+ # downloads both and merges them into a single multi-platform npm package.
104+ - name : Upload platform binaries
105+ uses : actions/upload-artifact@v4
106+ with :
107+ name : node-bin-${{ matrix.platform }}
108+ path : sdk/node/bin/
109+ retention-days : 7
110+
111+ # Upload the full package layout (JS + bin/ + bin-stubs) once — the
112+ # Linux runner's copy is the publish base; macOS just contributes its
113+ # bin/ subdir to the merge.
114+ - name : Upload full package (Linux base)
115+ if : matrix.platform == 'linux'
89116 uses : actions/upload-artifact@v4
90117 with :
91- name : npm-package-${{ matrix.platform }}
118+ name : npm-package-base
92119 path : sdk/node/
93120 retention-days : 7
94121
95122 publish :
96123 needs : build-packages
124+ if : ${{ !(inputs.prerelease || github.event.release.prerelease) }}
97125 runs-on : ubuntu-latest
98126 steps :
99- - name : Download Linux package
127+ - name : Download package base (Linux build)
128+ uses : actions/download-artifact@v4
129+ with :
130+ name : npm-package-base
131+ path : sdk/node-pkg
132+
133+ - name : Download macOS binaries
100134 uses : actions/download-artifact@v4
101135 with :
102- name : npm-package-linux
103- path : sdk/node-linux
136+ name : node-bin-macos
137+ path : sdk/node-bin-macos
138+
139+ - name : Merge macOS binaries into package
140+ run : |
141+ # Linux base already contains bin/<linux subdirs>/. Layer in the
142+ # macOS subdirs so the published package is multi-platform.
143+ for sub in sdk/node-bin-macos/*/; do
144+ name=$(basename "$sub")
145+ # Skip the .pilot-version file which is at the root, not a subdir.
146+ [ "$name" = ".pilot-version" ] && continue
147+ echo " merging bin/$name"
148+ cp -R "$sub" "sdk/node-pkg/bin/$name"
149+ done
150+ echo ""
151+ echo "Final bin/ layout:"
152+ find sdk/node-pkg/bin -maxdepth 2 -type d | sort
153+ echo ""
154+ echo "Files included by npm pack:"
155+ cd sdk/node-pkg && npm pack --dry-run 2>&1 | grep -E "\.(js|so|dylib)" | head -30
104156
105157 - name : Set up Node.js
106158 uses : actions/setup-node@v4
@@ -111,7 +163,7 @@ jobs:
111163 - name : Extract version
112164 id : extract-version
113165 run : |
114- VERSION=$(node -e "console.log(JSON.parse(require('fs').readFileSync('sdk/node-linux /package.json', 'utf8')).version)")
166+ VERSION=$(node -e "console.log(JSON.parse(require('fs').readFileSync('sdk/node-pkg /package.json', 'utf8')).version)")
115167 echo "version=$VERSION" >> $GITHUB_OUTPUT
116168 echo "Version: $VERSION"
117169
@@ -129,7 +181,7 @@ jobs:
129181
130182 - name : Publish to npm
131183 if : steps.check-npm.outputs.exists == 'false'
132- working-directory : sdk/node-linux
184+ working-directory : sdk/node-pkg
133185 env :
134186 NODE_AUTH_TOKEN : ${{ secrets.NPM_TOKEN }}
135187 run : |
@@ -147,9 +199,11 @@ jobs:
147199 echo "**Version:** ${{ steps.extract-version.outputs.version }}" >> $GITHUB_STEP_SUMMARY
148200 echo "**Install:** \`npm install pilotprotocol\`" >> $GITHUB_STEP_SUMMARY
149201 echo "**npm:** https://www.npmjs.com/package/pilotprotocol" >> $GITHUB_STEP_SUMMARY
202+ echo "**Platforms bundled:** linux-amd64, darwin-arm64" >> $GITHUB_STEP_SUMMARY
150203
151204 test-install :
152205 needs : publish
206+ if : ${{ !(inputs.prerelease || github.event.release.prerelease) }}
153207 strategy :
154208 matrix :
155209 os : [ubuntu-latest, macos-latest]
0 commit comments