|
1 | 1 | # WebUI package on the npm registry |
2 | 2 |
|
3 | 3 | The WebUI is packaged as `@fectivnfy112358/minimax-code-web` and published to |
4 | | -`https://registry.npmjs.org` with the `preview` dist-tag. The repository's |
5 | | -`.github/workflows/webui-npm-preview.yml` workflow publishes through npm trusted |
6 | | -publishing (OIDC) and holds no npm token. A trusted publisher can only be |
7 | | -configured once the package exists on npmjs.com, so the first version is |
8 | | -published from a machine that holds a token. |
| 4 | +`https://registry.npmjs.org` under the `preview` dist-tag. Publishing is fully |
| 5 | +automatic: every push to the `webui` branch builds the standalone package and |
| 6 | +publishes a new preview version. No tag, no version edit, no manual step. |
9 | 7 |
|
10 | | -## First publication |
| 8 | +## How a release happens |
11 | 9 |
|
12 | | -1. Build the package and inspect the tarball: |
| 10 | +`.github/workflows/webui-npm-preview.yml` runs on `push` to `webui` and on |
| 11 | +`workflow_dispatch`. It: |
13 | 12 |
|
14 | | - ```sh |
15 | | - pnpm install --frozen-lockfile |
16 | | - pnpm run package:webui-npm -- --version 0.1.0-preview.0 --outdir /tmp/minimax-code-web |
17 | | - npm pack --dry-run /tmp/minimax-code-web |
18 | | - ``` |
| 13 | +1. installs the workspace with a frozen lockfile; |
| 14 | +2. resolves the next version by reading the highest `<core>-preview.<n>` |
| 15 | + already on the registry and incrementing `n`; |
| 16 | +3. builds the package with `scripts/package-webui-npm.mjs`; |
| 17 | +4. inspects the tarball with `npm pack --dry-run`; |
| 18 | +5. publishes, unless that version is already on the registry, in which case it |
| 19 | + exits successfully without publishing. |
19 | 20 |
|
20 | | -2. Create a granular access token on npmjs.com with **Read and write (publish |
21 | | - and stage)** access. Put it in the user-level `~/.npmrc`; never in the |
22 | | - repository's `.npmrc`, which is tracked by Git: |
| 21 | +Because the version is derived from the registry rather than from a git tag or a |
| 22 | +field in the repository, the `version` in `release/webui-npm/package.json` is |
| 23 | +only the default for local builds. Editing it does not trigger or choose a |
| 24 | +release. |
23 | 25 |
|
24 | | - ```ini |
25 | | - //registry.npmjs.org/:_authToken=<token> |
26 | | - ``` |
| 26 | +The already-published check in step 5 is what makes reruns safe. A rerun of a |
| 27 | +successful run recomputes the same version, sees it published, and no-ops. |
27 | 28 |
|
28 | | -3. Publish the first version: |
| 29 | +## Credentials |
29 | 30 |
|
30 | | - ```sh |
31 | | - npm publish /tmp/minimax-code-web --tag preview |
32 | | - ``` |
| 31 | +The workflow authenticates with the repository secret `NPM_TOKEN`, which must be |
| 32 | +a granular access token with **Read and write (publish and stage)** access to |
| 33 | +`@fectivnfy112358`. It is read as `NODE_AUTH_TOKEN`, which `actions/setup-node` |
| 34 | +turns into the `//registry.npmjs.org/:_authToken` entry the publish step needs. |
33 | 35 |
|
34 | | - `publishConfig.access` in `release/webui-npm/package.json` already makes the |
35 | | - scoped package public. |
| 36 | +Set it once: |
36 | 37 |
|
37 | | -## Enable trusted publishing |
| 38 | +```sh |
| 39 | +gh secret set NPM_TOKEN --repo <owner>/<repo> |
| 40 | +``` |
38 | 41 |
|
39 | | -On npmjs.com, open the package settings, add a trusted publisher for GitHub |
40 | | -Actions, and use: |
| 42 | +The workflow holds no npm token in the repository, and no token belongs in the |
| 43 | +tracked `.npmrc`. |
41 | 44 |
|
42 | | -- **Organization or user**: `fectivnfy112358` |
43 | | -- **Repository**: `minimax-code` |
44 | | -- **Workflow filename**: `webui-npm-preview.yml` (filename only, including the |
45 | | - extension) |
46 | | -- **Environment name**: leave empty |
47 | | -- **Allowed actions**: `npm publish` |
| 45 | +## Publishing attestations |
48 | 46 |
|
49 | | -The workflow declares no GitHub environment and no `NODE_AUTH_TOKEN`, so these |
50 | | -values must stay in sync with it. Once a tag-triggered release has been verified, |
51 | | -revoke the token from step 2. |
| 47 | +The workflow does **not** pass `--provenance`, so published versions carry no |
| 48 | +npm provenance attestation. Provenance requires npm trusted publishing (OIDC), |
| 49 | +which in turn requires the package's trusted publisher to be configured on |
| 50 | +npmjs.com. If that configuration is ever added, give the workflow |
| 51 | +`permissions: id-token: write` and pass `--provenance` to the publish step; |
| 52 | +`repository.url` in `release/webui-npm/package.json` must keep matching the |
| 53 | +GitHub repository or attestation generation fails. |
52 | 54 |
|
53 | | -## Publish a preview |
| 55 | +## Local builds |
54 | 56 |
|
55 | | -1. Merge the intended changes into `webui` and confirm the package build is |
56 | | - ready. |
57 | | -2. Create a tag on that commit using the package version, for example |
58 | | - `webui-v0.1.0-preview.1`. |
59 | | -3. Push that tag. The workflow checks the preview version format, builds the |
60 | | - standalone package, inspects the npm tarball contents, then publishes to |
61 | | - `https://registry.npmjs.org` with the `preview` dist-tag. |
| 57 | +`release/webui-npm/package.json` carries the version a local build falls back to |
| 58 | +when `--version` is omitted. npm never accepts a republished version, so a local |
| 59 | +build that is meant to be published needs an explicit, unused version: |
62 | 60 |
|
63 | | -Provenance attestations are generated automatically by the trusted publish; the |
64 | | -`--provenance` flag is not needed. `repository.url` in |
65 | | -`release/webui-npm/package.json` must keep matching the GitHub repository or |
66 | | -provenance validation fails. |
| 61 | +```sh |
| 62 | +pnpm install --frozen-lockfile |
| 63 | +pnpm run package:webui-npm -- --version 0.1.0-preview.4 --outdir /tmp/minimax-code-web |
| 64 | +npm pack --dry-run /tmp/minimax-code-web |
| 65 | +``` |
| 66 | + |
| 67 | +`publishConfig.access` in `release/webui-npm/package.json` already makes the |
| 68 | +scoped package public. |
0 commit comments