Commit 3efb994
fix(ci): publish release with npm instead of ut publish (#6016)
## Motivation
The [Manual Release
run](https://github.com/eggjs/egg/actions/runs/28323984300/job/83910742571)
failed at the **Publish packages** step:
```
📦 Publishing 79 packages (tag: beta, provenance)
error: unexpected argument '--access' found
Usage: ut publish [OPTIONS]
```
`ut publish` does not accept npm-native flags (`--access`,
`--provenance`), and more importantly it cannot do npm **trusted
publishing / provenance via OIDC** — which is the whole reason the
release workflow uses them. So this switches `scripts/publish.js` back
to `npm publish`.
## The catch: npm doesn't replicate everything `pnpm publish` did
A naive `ut` → `npm` swap would publish **broken** packages, because npm
understands neither of two things that `pnpm publish` handled for us
before the utoo migration:
1. **`workspace:` / `catalog:` protocol specifiers.** 79 publishable
packages ship `workspace:*`, `catalog:` and `catalog:path-to-regexp1` in
their runtime `dependencies` (984 such specs). npm publishes them
verbatim → uninstallable packages.
2. **`publishConfig` field hoisting.** 77/79 packages set a dev-time
root `exports` pointing at `./src/*.ts` and a `publishConfig.exports`
pointing at compiled `./dist/*.js`. pnpm hoists `publishConfig` on
publish; **npm does not**. Since `files: ["dist"]`, the source isn't
even in the tarball — every consumer's `import 'egg'` would resolve to a
non-existent `./src/index.ts`. (npm exits 0 either way, so it fails
silently.)
## Changes
`scripts/publish.js` now prepares each manifest right before `npm
publish` and restores it in a `finally` (crash-safe), mirroring pnpm:
- resolve `workspace:*` → exact in-repo version, `workspace:^`/`~` →
prefixed; `catalog:` / `catalog:<name>` → the spec from
`pnpm-workspace.yaml`
- hoist `publishConfig` overrides (notably `exports`) onto the top-level
manifest
`scripts/utils.js` gains `getWorkspaceVersionMap`, `getCatalogs`,
`resolveWorkspaceProtocols`, and `applyPublishConfigOverrides` (and a
`collectWorkspacePackages` refactor that keeps `getPublishablePackages`
behavior identical). Also: `isPublished()` now uses the resolved
`npm`/`npm.cmd` binary for Windows parity, and a redundant
`.filter(!private)` in `sync-cnpm.js` is dropped.
## Tests / verification
- Across **all 79 publishable packages / 984 deps**: 0 leftover
`workspace:`/`catalog:` specifiers after rewrite; every `workspace:*` →
exact version, every `catalog:` → its table spec.
- **Ground-truth match** against the last pnpm-published manifests on
npm: `@eggjs/router` (`path-to-regexp: ^1.9.0` via the named catalog),
`@eggjs/security` (`@eggjs/ip: ^2.1.0`, `@eggjs/path-matching` exact),
and `@eggjs/core` reproduce exactly.
- `publishConfig.exports` hoisted for all 77 packages that declare it;
**0** resolved `exports` left pointing at `src/`.
- Real `npm pack` of `@eggjs/core` with the full rewrite produces
`exports["."] = "./dist/index.js"`; the manifest is restored afterwards
(git clean).
- `npm publish --dry-run` accepts `--access`/`--tag`/`--dry-run` (the
flags `ut publish` rejected).
- `oxfmt --check` and `oxlint --type-aware` clean; pre-commit hook
passes.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit
* **New Features**
* Publishing now supports workspace-linked and catalog-based
dependency/version resolution for each package.
* Publish settings are applied automatically during publishing so
released metadata stays consistent.
* **Bug Fixes**
* Prevents leaving modified manifests behind by restoring package files
after publish operations, even on failure.
* Improved cross-platform publishing behavior (including Windows).
* **Behavior Changes**
* Dry-run no longer retries after simulated failures; failures are
reported accurately for visibility.
* Still skips packages already available on the registry and retries
failed publishes once (non-dry-run).
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
---------
Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>1 parent 10705cd commit 3efb994
3 files changed
Lines changed: 245 additions & 69 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
6 | | - | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
7 | 14 | | |
8 | 15 | | |
9 | 16 | | |
| |||
14 | 21 | | |
15 | 22 | | |
16 | 23 | | |
| 24 | + | |
17 | 25 | | |
18 | 26 | | |
19 | | - | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
20 | 34 | | |
21 | 35 | | |
22 | 36 | | |
| |||
30 | 44 | | |
31 | 45 | | |
32 | 46 | | |
33 | | - | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
34 | 50 | | |
35 | 51 | | |
36 | 52 | | |
| |||
41 | 57 | | |
42 | 58 | | |
43 | 59 | | |
44 | | - | |
| 60 | + | |
45 | 61 | | |
46 | 62 | | |
47 | 63 | | |
| |||
55 | 71 | | |
56 | 72 | | |
57 | 73 | | |
58 | | - | |
59 | | - | |
60 | | - | |
61 | | - | |
62 | | - | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
63 | 80 | | |
64 | 81 | | |
65 | 82 | | |
66 | 83 | | |
67 | 84 | | |
68 | 85 | | |
69 | | - | |
70 | | - | |
71 | | - | |
72 | | - | |
73 | | - | |
74 | | - | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
75 | 107 | | |
76 | 108 | | |
77 | 109 | | |
| |||
105 | 137 | | |
106 | 138 | | |
107 | 139 | | |
108 | | - | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
109 | 144 | | |
110 | | - | |
111 | | - | |
112 | | - | |
113 | | - | |
114 | | - | |
115 | | - | |
116 | | - | |
117 | | - | |
118 | | - | |
119 | | - | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
120 | 149 | | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
121 | 155 | | |
122 | | - | |
123 | | - | |
124 | | - | |
125 | | - | |
126 | | - | |
127 | 156 | | |
128 | | - | |
| 157 | + | |
129 | 158 | | |
130 | | - | |
131 | | - | |
132 | | - | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
133 | 174 | | |
134 | 175 | | |
135 | 176 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
10 | | - | |
| 10 | + | |
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
| |||
0 commit comments