Skip to content

Commit daa9afd

Browse files
committed
ci: fix ci
1 parent 03914f3 commit daa9afd

1 file changed

Lines changed: 23 additions & 2 deletions

File tree

.github/workflows/publish.yml

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,12 @@ jobs:
2727
registry-url: 'https://registry.npmjs.org'
2828
# OIDC 认证会自动处理,不需要 NODE_AUTH_TOKEN
2929

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+
3036
- name: Setup pnpm
3137
uses: pnpm/action-setup@v4
3238
with:
@@ -100,13 +106,28 @@ jobs:
100106
echo "Checking npm config:"
101107
npm config list || true
102108
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)"
103118
104119
- name: Create Release Pull Request or Publish to npm
105120
id: changesets
106121
uses: changesets/action@v1
107122
with:
108123
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
111132
env:
112133
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)