pdf-h5-react 0.3.0 → 0.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +34 -9
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -396,11 +396,9 @@ npm run dev # http://127.0.0.1:5273
|
|
|
396
396
|
|
|
397
397
|
## 发布
|
|
398
398
|
|
|
399
|
-
发布由 [GitHub Actions](.github/workflows/release.yml)
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
(npmjs.com 的 Automation token,权限只需 *Read and write*)。
|
|
403
|
-
GitHub 自带的 `GITHUB_TOKEN` 只能发 GitHub Packages,发不了 npmjs,因此必须配这个 Secret。
|
|
399
|
+
发布由 [GitHub Actions](.github/workflows/release.yml) 通过 **Trusted Publishing (OIDC)** 完成,推 tag 即触发。
|
|
400
|
+
**不需要任何 Secret**:Actions 每次运行签发短期 OIDC token,npm 校验它是否匹配包的
|
|
401
|
+
trusted publisher 配置(仓库 + workflow 文件名),通过即授权发布。
|
|
404
402
|
|
|
405
403
|
```bash
|
|
406
404
|
# 1. 改版本号
|
|
@@ -417,15 +415,42 @@ node scripts/publish-gh.mjs --tag 0.4.0
|
|
|
417
415
|
也可以在 [Actions 页面](https://github.com/superjunjie/pdf-h5-react/actions/workflows/release.yml)
|
|
418
416
|
手动触发 `Run workflow`,并用输入框覆盖版本号。
|
|
419
417
|
|
|
420
|
-
###
|
|
418
|
+
### 一次性配置(已配好,仅供换仓库时参考)
|
|
419
|
+
|
|
420
|
+
npmjs.com → 包的 **Settings → Trusted publishing** → Add a trusted publisher:
|
|
421
|
+
|
|
422
|
+
| 字段 | 值 |
|
|
423
|
+
| --- | --- |
|
|
424
|
+
| Provider | GitHub Actions |
|
|
425
|
+
| Organization or user | `superjunjie` |
|
|
426
|
+
| Repository | `pdf-h5-react` |
|
|
427
|
+
| Workflow filename | `release.yml`(**只填文件名**,不含 `.github/workflows/`) |
|
|
428
|
+
| Environment name | 留空(workflow 未使用 environment) |
|
|
429
|
+
| Allowed actions | 勾选 **`npm publish`** |
|
|
430
|
+
|
|
431
|
+
两个容易踩的坑:
|
|
421
432
|
|
|
422
|
-
|
|
433
|
+
- **`Workflow filename` 只填文件名**,写成 `.github/workflows/release.yml` 会导致 OIDC 换 token 失败。
|
|
434
|
+
- **必须勾 `npm publish`**。2026-09-03 之后新建的配置默认只允许 `npm stage publish`,
|
|
435
|
+
只勾 stage 的话 OIDC 能通过、但只能暂存,仍需人工批准。
|
|
436
|
+
- 改名仓库或 workflow 文件名后,必须同步更新这里,否则发布会失败。
|
|
437
|
+
|
|
438
|
+
> **首次发布不能用 OIDC**:npm 要求包已存在于 registry 才能配置 trusted publisher,
|
|
439
|
+
> 而 staged publishing 也不支持全新包。所以新包的第一次发布必须是直接发布
|
|
440
|
+
> (交互式 2FA 或带 bypass-2FA 的 token),之后 OIDC 才可用。
|
|
441
|
+
|
|
442
|
+
### 手动发布(本地兜底)
|
|
443
|
+
|
|
444
|
+
CI 不可用时可在本地发,但对新版本通常需要交互式 2FA:
|
|
423
445
|
|
|
424
446
|
```bash
|
|
425
|
-
npm run build && npm publish
|
|
447
|
+
npm run build && npm publish # prepublishOnly 会自动跑 typecheck + test + build
|
|
426
448
|
```
|
|
427
449
|
|
|
450
|
+
> npm 正在收紧长期 token:带 bypass-2FA 的 granular token 约 2027-01 失去直接发布能力,
|
|
451
|
+
> 2026-09 起新增的「Read and write (stage only)」token 只能 `npm stage publish`、不能直接发。
|
|
452
|
+
> OIDC 是目前唯一支持无人值守发布的路径。
|
|
453
|
+
|
|
428
454
|
## License
|
|
429
455
|
|
|
430
456
|
MIT
|
|
431
|
-
|