Skip to content

feat(js-host-api): add npm publishing workflow#36

Open
simongdavies wants to merge 1 commit intomainfrom
feat/npm-publish
Open

feat(js-host-api): add npm publishing workflow#36
simongdavies wants to merge 1 commit intomainfrom
feat/npm-publish

Conversation

@simongdavies
Copy link
Contributor

Summary

Adds cross-platform npm publishing for @hyperlight/js-host-api.

Changes

  • npm-publish.yml - New workflow that builds native binaries on Linux/Windows and publishes to npmjs.com
  • CreateRelease.yml - Calls npm-publish after creating GitHub release
  • package.json - Added napi targets and optionalDependencies for platform packages
  • npm/ - Platform-specific package.json files for Linux and Windows
  • .npmignore - Controls what gets published (includes generated index.js/index.d.ts)
  • README.md - Added publishing documentation

Usage

  • Manual: Actions → "Publish npm packages" → Run workflow (with optional dry-run)
  • Automatic: Triggers after CreateRelease on release/vX.Y.Z branches

Setup Required

Add NPM_TOKEN secret (npm access token with publish permissions for @hyperlight scope)

- Add npm-publish.yml workflow for cross-platform builds (Linux/Windows x64)
- Add platform-specific npm packages for native binaries
- Integrate npm publish into CreateRelease workflow
- Add .npmignore to control published files
- Update README with publishing documentation
@simongdavies simongdavies added the kind/enhancement New feature or improvement label Mar 3, 2026
Copy link
Contributor

@jprendes jprendes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, it would be great if we could test it in a local repo before publishing to npm, to make sure that it works as expected. There is a lot of nodejs magic in here :-)

required: false
type: boolean
default: false
secrets:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need secrets in workflow_dispatch too? or does this cover both?

"binaryName": "js-host-api"
"binaryName": "js-host-api",
"targets": [
"x86_64-unknown-linux-gnu",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we want a musl build?

Comment on lines +23 to +26
"optionalDependencies": {
"@hyperlight/js-host-api-linux-x64-gnu": "0.17.0",
"@hyperlight/js-host-api-win32-x64-msvc": "0.17.0"
},
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A link to the napi-rs explaining how this would would be helpful (at least for future me), although I think we can't put comments in package.json, right? :-(
https://napi.rs/docs/deep-dive/release#3-the-native-addon-for-different-platforms-is-distributed-through-different-npm-packages
Also, that link seems to imply that you need "os" and "cpu" fields in this package as well, right?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kind/enhancement New feature or improvement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants