|
27 | 27 | registry-url: 'https://registry.npmjs.org' |
28 | 28 | # OIDC 认证会自动处理,不需要 NODE_AUTH_TOKEN |
29 | 29 |
|
| 30 | + - name: Upgrade npm to latest (for OIDC support) |
| 31 | + run: | |
| 32 | + # 确保 npm 版本 >= 11.5.1 以支持 Trusted Publishing |
| 33 | + npm install -g npm@latest |
| 34 | + npm --version |
| 35 | +
|
30 | 36 | - name: Setup pnpm |
31 | 37 | uses: pnpm/action-setup@v4 |
32 | 38 | with: |
@@ -100,13 +106,28 @@ jobs: |
100 | 106 | echo "Checking npm config:" |
101 | 107 | npm config list || true |
102 | 108 | echo "=== End debugging ===" |
| 109 | + |
| 110 | + - name: Test OIDC authentication (dry-run) |
| 111 | + run: | |
| 112 | + echo "Testing OIDC authentication with a dry-run publish..." |
| 113 | + # 尝试一个 dry-run 发布来测试 OIDC |
| 114 | + # 注意:这可能会失败,但可以帮助诊断问题 |
| 115 | + cd "$(mktemp -d)" |
| 116 | + echo '{"name":"@arkts/test-oidc","version":"0.0.0-test"}' > package.json |
| 117 | + npm publish --dry-run --registry=https://registry.npmjs.org/ 2>&1 | head -20 || echo "Dry-run completed (errors expected for test package)" |
103 | 118 |
|
104 | 119 | - name: Create Release Pull Request or Publish to npm |
105 | 120 | id: changesets |
106 | 121 | uses: changesets/action@v1 |
107 | 122 | with: |
108 | 123 | createGithubReleases: true |
109 | | - # 使用 npx changeset publish (通过 npm) 而不是 pnpm,以确保 OIDC 正常工作 |
110 | | - publish: npx changeset publish |
| 124 | + # 使用 npm 直接发布,确保 OIDC 正常工作 |
| 125 | + # changesets 会先准备发布,然后我们手动发布 |
| 126 | + publish: | |
| 127 | + echo "Preparing to publish with OIDC..." |
| 128 | + # 确保使用最新的 npm 和正确的配置 |
| 129 | + npm config set registry https://registry.npmjs.org/ |
| 130 | + # 运行 changeset publish,它会使用 npm publish |
| 131 | + npx changeset publish |
111 | 132 | env: |
112 | 133 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
0 commit comments