ci: make a repeated release a no-op and drop the misleading diagnostics
Gitea does not implement the npm whoami endpoint and npm refuses to read an auth token back, so both lines only produced error-looking output. The run now checks the registry first and skips publishing a version that already exists, which also makes a manual re-run safe.
This commit is contained in:
@@ -88,8 +88,9 @@ git tag -a v1.0.1 -m "v1.0.1" && git push origin v1.0.1
|
||||
前提与排查:
|
||||
|
||||
- 实例启用了 Actions 并注册了 runner(`runs-on: ubuntu-latest` 要与 runner 的标签一致);
|
||||
- 若组织把 Actions 令牌上限设成只读,或任务令牌对包命名空间没有写权限,发布步骤会很快失败:在仓库 Settings → Actions → Secrets 添加 `NPM_TOKEN` 即可,工作流会自动改用它;
|
||||
- 失败时先看该步骤日志里 `npm whoami` 的输出:打印出用户名说明令牌可用(错误就只可能是版本已存在或包名不合法),报 `E401/E403` 则是令牌无效或权限不足。
|
||||
- 若组织把 Actions 令牌上限设成只读,或任务令牌对包命名空间没有写权限,发布步骤会很快失败:配置 `NPM_TOKEN` 即可,工作流会自动改用它;
|
||||
- 已发布的版本会在发布前被检测到并**跳过**,所以手动重跑同一个版本是安全的(不会失败,也不再重复上传);
|
||||
- 真失败时看 `Publish` 步骤日志:`registry =` 那行确认注册表地址,`npm error code` 给出原因(`E401/E403` = 令牌无效或权限不足)。注意 Gitea 的 npm 注册表**不实现** `/-/whoami`,`npm whoami` 返回 404 属正常现象;`npm config get ...:_authToken` 也必然报 protected,因为 npm 禁止读回令牌。
|
||||
|
||||
手工发布等价于:
|
||||
|
||||
|
||||
Reference in New Issue
Block a user