Commit Graph

2 Commits

Author SHA1 Message Date
Boshen 4da5da8eed fix(ci): skip already-published npm packages instead of erroring (#20173)
## Summary

- CI publish workflow fails when re-run after a partial publish because
npm rejects republishing an existing version
- Add version-published checks to `check-npm-packages.js` so
already-published packages are skipped in the dry-run step
- Extract a shared `publish-if-needed.sh` script that checks the npm
registry before publishing, used by all three trusted publish steps
- Consolidate the old `checkPackageExists` and new version check into a
single `npmViewVersion` helper to avoid redundant npm registry calls

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-10 13:20:59 +08:00
Boshen 7452e08cb0 chore(ci): Check npm packages exist before publishing (#16397)
npm Trusted Publishing requires the package to already exist on npm
before it can be published in a “trusted” workflow.

The current workflow looks like this, for example, if we have 10 NAPI
packages:

* I added a new NAPI package and forgot about it.
* During release, CI tries to release 5 packages.
* CI encounters the missing package, errors out with “package not
found,” and exits.
* I then publish the missing package locally.
* I can’t retry the CI publish process, because the retry immediately
fails with “package already published.”

So we need to check that *all* packages exist on npm **before**
publishing anything. This allows us to publish any missed packages
without breaking the entire release process.

Co-authored-by: Claude <noreply@anthropic.com>
2025-12-03 12:48:08 +08:00