You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/release.md
+59Lines changed: 59 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -53,8 +53,67 @@ This release contains the benchmark results and the source code for the release
53
53
54
54
In addition the hyperlight-js crates will be published to crates.io. You can verify this by going to the [hyperlight-js page on crates.io](https://crates.io/crates/hyperlight-js) and checking that the new version is listed.
55
55
56
+
The npm packages (`@hyperlight-dev/js-host-api` and platform-specific binaries) are also published automatically as part of this workflow. Publishing uses [npm trusted publishing (OIDC)](https://docs.npmjs.com/trusted-publishers) — no `NPM_TOKEN` secret is needed for the `CreateRelease` workflow. Provenance attestations are generated automatically.
57
+
58
+
You can verify the npm publish by checking the [npmjs.com package page](https://www.npmjs.com/package/@hyperlight-dev/js-host-api).
59
+
60
+
### npm trusted publishing setup
61
+
62
+
Trusted publishing is configured on [npmjs.com](https://www.npmjs.com/) for each package. If you add a new platform package, you must configure its trusted publisher:
63
+
64
+
1. Go to the package on npmjs.com → Settings → Trusted Publisher
65
+
2. Select **GitHub Actions**
66
+
3. Set **Organization**: `hyperlight-dev`, **Repository**: `hyperlight-js`, **Workflow**: `CreateRelease.yml`
67
+
4. Save
68
+
69
+
This must be done for all 4 packages:
70
+
-`@hyperlight-dev/js-host-api`
71
+
-`@hyperlight-dev/js-host-api-linux-x64-gnu`
72
+
-`@hyperlight-dev/js-host-api-linux-x64-musl`
73
+
-`@hyperlight-dev/js-host-api-win32-x64-msvc`
74
+
75
+
> **Note:** Trusted publishing only works via `CreateRelease.yml` (the production release path). Manual publishing is deliberately discouraged — see [Manual npm publishing (emergency only)](#manual-npm-publishing-emergency-only) below.
76
+
56
77
## Patching a release
57
78
58
79
If you need to update a previously released version of hyperlight-js then you should open a Pull Request against the release branch you want to patch, for example if you wish to patch the release `v0.18.0` then you should open a PR against the `release/v0.18.0` branch.
59
80
60
81
Once the PR is merged, then you should follow the instructions above. In this instance the version number of the tag should be a patch version, for example if you are patching the `release/v0.18.0` branch and this is the first patch release to that branch then the tag should be `v0.18.1`. If you are patching a patch release then the tag should be `v0.18.2` and the target branch should be `release/v0.18.1` and so on.
82
+
83
+
## Manual npm publishing (emergency only)
84
+
85
+
> ⚠️ **Do not use this for regular releases.** Use the `CreateRelease` workflow instead. Manual publishing bypasses OIDC trusted publishing and will **not** generate provenance attestations — meaning publish will show up without the "Published via trusted publishing" badge on npmjs.com. Only use this if the automated release pipeline is broken and you need to ship an urgent fix.
86
+
87
+
If you need to publish npm packages manually via `workflow_dispatch`, you'll need to:
88
+
89
+
1.**Temporarily allow token-based publishing on npmjs.com**
90
+
- Go to each package on [npmjs.com](https://www.npmjs.com/) → Settings → Publishing access
91
+
- Change from "Require two-factor authentication and disallow tokens" to "Require two-factor authentication or automation tokens"
92
+
- Do this for all 4 packages:
93
+
-`@hyperlight-dev/js-host-api`
94
+
-`@hyperlight-dev/js-host-api-linux-x64-gnu`
95
+
-`@hyperlight-dev/js-host-api-linux-x64-musl`
96
+
-`@hyperlight-dev/js-host-api-win32-x64-msvc`
97
+
98
+
2.**Create an npm automation token**
99
+
- Go to [npmjs.com](https://www.npmjs.com/) → Access Tokens → Generate New Token → Granular Access Token
100
+
- Set scope to the `@hyperlight-dev` org, packages: read and write, expiry: shortest available
101
+
- Copy the token
102
+
103
+
3.**Add the token as a repo secret**
104
+
- Go to the repo on GitHub → Settings → Secrets and variables → Actions → New repository secret
105
+
- Name: `NPM_TOKEN`
106
+
- Value: paste the token from the previous step
107
+
- Save
108
+
109
+
4.**Run the workflow**
110
+
- Go to Actions → "Publish npm packages" → Run workflow
111
+
- Select the correct branch
112
+
- Enter the version (e.g. `0.2.1`)
113
+
- Set `dry-run` to `false`
114
+
115
+
5.**Clean up immediately after publishing**
116
+
- Delete the `NPM_TOKEN` repo secret on GitHub → Settings → Secrets and variables → Actions
117
+
- Revoke the npm token on npmjs.com → Access Tokens
118
+
- Re-enable "Require two-factor authentication and disallow tokens" on all 4 packages
119
+
- Verify the packages published correctly: `npm view @hyperlight-dev/js-host-api versions`
Development, build, and publishing instructions for contributors.
4
+
5
+
## Requirements
6
+
7
+
-**Node.js** >= 18
8
+
-**Rust** toolchain (see `rust-toolchain.toml` in repository root)
9
+
-**just** (build automation) — install via `cargo install just` or your package manager
10
+
11
+
## Building from Source
12
+
13
+
### Build Commands
14
+
15
+
```bash
16
+
# Install dependencies
17
+
npm install
18
+
19
+
# Release builds (optimized)
20
+
npm run build
21
+
22
+
# Debug builds (with symbols)
23
+
npm run build:debug
24
+
25
+
# Run tests
26
+
npm test
27
+
```
28
+
29
+
### Using Just (Build Automation)
30
+
31
+
From the repository root:
32
+
33
+
```bash
34
+
# Build js-host-api
35
+
just build-js-host-api release
36
+
37
+
# Build with debug symbols
38
+
just build-js-host-api debug
39
+
40
+
# Run js-host-api examples
41
+
just run-js-host-api-examples release
42
+
43
+
# Run js-host-api tests
44
+
just test-js-host-api release
45
+
46
+
# Build and test everything (all runtimes and targets)
47
+
just build-all
48
+
just test-all release
49
+
```
50
+
51
+
## Publishing to npm
52
+
53
+
The package is published to npmjs.com as `@hyperlight-dev/js-host-api` with platform-specific binary packages using [npm trusted publishing (OIDC)](https://docs.npmjs.com/trusted-publishers).
54
+
55
+
> **Note:** You cannot `npm publish` from your local machine. Publishing is handled by CI via the `CreateRelease` workflow, which uses OIDC for authentication. Trusted publishing must be configured on npmjs.com — see [docs/release.md](../../docs/release.md) for full setup and release instructions.
56
+
57
+
**For release instructions, see [docs/release.md](../../docs/release.md).**
58
+
59
+
### Package Structure
60
+
61
+
The npm release consists of the following packages:
62
+
63
+
| Package | Description |
64
+
|---------|-------------|
65
+
|`@hyperlight-dev/js-host-api`| Main package (installs correct binary automatically) |
66
+
|`@hyperlight-dev/js-host-api-linux-x64-gnu`| Linux x86_64 (glibc) native binary |
67
+
|`@hyperlight-dev/js-host-api-linux-x64-musl`| Linux x86_64 (musl/Alpine) native binary |
68
+
|`@hyperlight-dev/js-host-api-win32-x64-msvc`| Windows x86_64 native binary |
69
+
70
+
### How Platform Selection Works
71
+
72
+
This project uses the [napi-rs](https://napi.rs/docs/deep-dive/release#3-the-native-addon-for-different-platforms-is-distributed-through-different-npm-packages) approach for distributing native addons across platforms. Each platform-specific binary is published as a separate npm package and listed as an `optionalDependency` of the main package.
73
+
74
+
**At install time:** npm uses the `os`, `cpu`, and `libc` fields in each platform sub-package's `package.json` to determine which optional dependency to install. Packages that don't match the user's platform are silently skipped. The main package itself does **not** have `os`/`cpu` fields because it contains only JavaScript — restricting it would prevent installation on unsupported platforms even for type-checking or development purposes.
75
+
76
+
**At runtime:** The napi-rs generated `index.js` detects the platform (including glibc vs musl on Linux) and loads the correct `.node` binary.
0 commit comments