Skip to content

Commit ffc2916

Browse files
committed
ci: add validation guards for npm publish safety
- Verify package.json version matches git tag before publish - Validate TypeScript build output (dist/index.js, dist/index.d.ts) - Validate all 5 platform native addons are present in Release/
1 parent af966bc commit ffc2916

1 file changed

Lines changed: 33 additions & 0 deletions

File tree

.github/workflows/build.yml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -337,12 +337,45 @@ jobs:
337337
find artifacts -name "*.node" -exec cp {} Release/ \;
338338
ls -lh Release/
339339
340+
- name: Verify version consistency
341+
if: startsWith(github.ref, 'refs/tags/v')
342+
run: |
343+
PKG_VERSION=$(node -p "require('./package.json').version")
344+
TAG_VERSION=${GITHUB_REF#refs/tags/v}
345+
if [ "$PKG_VERSION" != "$TAG_VERSION" ]; then
346+
echo "❌ Version mismatch: package.json=$PKG_VERSION, tag=$TAG_VERSION"
347+
exit 1
348+
fi
349+
echo "✅ Version consistent: $PKG_VERSION"
350+
340351
- name: Install dependencies (skip native build)
341352
run: npm ci --ignore-scripts
342353

343354
- name: Build TypeScript
344355
run: npm run build:ts
345356

357+
- name: Validate build output
358+
run: |
359+
echo "Validating TypeScript build..."
360+
if [ ! -f "dist/index.js" ]; then
361+
echo "❌ dist/index.js not found"
362+
exit 1
363+
fi
364+
if [ ! -f "dist/index.d.ts" ]; then
365+
echo "❌ dist/index.d.ts not found"
366+
exit 1
367+
fi
368+
echo "✅ TypeScript build verified"
369+
370+
echo "Validating native addons..."
371+
for f in linux-x86_64-gnu linux-aarch64-gnu linux-x86_64-musl linux-aarch64-musl darwin-universal; do
372+
if [ ! -f "Release/${f}-rocketmq.node" ]; then
373+
echo "❌ Missing: ${f}-rocketmq.node"
374+
exit 1
375+
fi
376+
done
377+
echo "✅ All native addons present"
378+
346379
- name: Verify package contents
347380
run: |
348381
echo "=== Package contents ==="

0 commit comments

Comments
 (0)