Skip to content

Commit b6a207e

Browse files
committed
Fix publish: set optionalDependencies directly instead of neon install-builds
neon install-builds queries the npm registry for platform packages, but since they were just published moments before, a propagation delay can cause some targets to resolve as npm:null@* (which installs a bogus "null" package instead of the native bindings). This broke linux-x64-gnu and linux-x64-musl in 0.5.26. Instead, set optionalDependencies deterministically from neon.targets config and skip the prepack script with --ignore-scripts.
1 parent f0284d0 commit b6a207e

1 file changed

Lines changed: 30 additions & 11 deletions

File tree

.github/workflows/CI.yml

Lines changed: 30 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -135,8 +135,29 @@ jobs:
135135
uses: actions/download-artifact@v4
136136
with:
137137
path: artifacts
138-
- name: List packages
139-
run: ls -R artifacts/
138+
- name: Collect platform tarballs
139+
run: |
140+
mkdir -p dist
141+
for dir in artifacts/bindings-*; do
142+
cp "$dir"/*.tgz dist/
143+
done
144+
ls -la dist/
145+
shell: bash
146+
- name: Set optionalDependencies
147+
run: |
148+
VERSION=$(node -p "require('./package.json').version")
149+
node -e "
150+
const fs = require('fs');
151+
const pkg = JSON.parse(fs.readFileSync('package.json', 'utf8'));
152+
const targets = pkg.neon.targets;
153+
pkg.optionalDependencies = {};
154+
for (const [rustTarget, npmName] of Object.entries(targets)) {
155+
pkg.optionalDependencies[npmName] = '${VERSION}';
156+
}
157+
fs.writeFileSync('package.json', JSON.stringify(pkg, null, 2) + '\n');
158+
"
159+
echo "optionalDependencies set:"
160+
node -p "JSON.stringify(require('./package.json').optionalDependencies, null, 2)"
140161
shell: bash
141162
- name: Publish
142163
run: |
@@ -154,17 +175,15 @@ jobs:
154175
fi
155176
156177
# Publish platform packages first
157-
for dir in artifacts/bindings-*; do
158-
for tgz in "$dir"/*.tgz; do
159-
if [ -f "$tgz" ]; then
160-
echo "Publishing $tgz..."
161-
npm publish "$tgz" --access public --provenance $TAG_ARGS
162-
fi
163-
done
178+
for tgz in dist/*.tgz; do
179+
if [ -f "$tgz" ]; then
180+
echo "Publishing $tgz..."
181+
npm publish "$tgz" --access public --provenance $TAG_ARGS
182+
fi
164183
done
165184
166-
# Publish main package
167-
npm publish --access public --provenance $TAG_ARGS
185+
# Publish main package (skip prepack/neon install-builds since we set optionalDependencies above)
186+
npm publish --access public --provenance --ignore-scripts $TAG_ARGS
168187
env:
169188
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
170189
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

0 commit comments

Comments
 (0)