Skip to content

Commit 07be7da

Browse files
committed
feat: publish with iodc
1 parent 05fc4ab commit 07be7da

2 files changed

Lines changed: 55 additions & 1 deletion

File tree

‎.github/workflows/publish.yml‎

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
name: Publish Package
2+
3+
on:
4+
push:
5+
tags:
6+
- '*.*.*'
7+
8+
# OIDC Trusted Publishing 需要以下权限
9+
# - id-token: write - 允许 GitHub Actions 生成 OIDC token
10+
# - contents: read - 允许读取仓库内容
11+
permissions:
12+
id-token: write
13+
contents: read
14+
15+
jobs:
16+
publish:
17+
runs-on: ubuntu-latest
18+
19+
steps:
20+
- name: Checkout
21+
uses: actions/checkout@v4
22+
23+
- name: Setup pnpm
24+
uses: pnpm/action-setup@v4
25+
with:
26+
version: 9
27+
28+
- name: Setup Node.js
29+
uses: actions/setup-node@v4
30+
with:
31+
node-version: '20'
32+
registry-url: 'https://registry.npmjs.org'
33+
34+
# 确保使用最新版本的 npm 以支持 Trusted Publishing
35+
- name: Update npm
36+
run: npm install -g npm@latest
37+
38+
- name: Install dependencies
39+
run: pnpm install
40+
41+
- name: Run build
42+
run: pnpm build
43+
44+
- name: Run tests
45+
run: pnpm test
46+
47+
# 使用 OIDC Trusted Publishing 发布,无需 token
48+
# 在 npmjs.com 上配置 Trusted Publisher 后,npm 会自动使用 OIDC 认证
49+
- name: Publish to npm
50+
run: npm publish --access public

‎package.json‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,5 +39,9 @@
3939
"typescript": "^5.0.0",
4040
"vitest": "^3.2.6"
4141
},
42-
"repository": "git@github.com:antvis/context.git"
42+
"repository": "git@github.com:antvis/context.git",
43+
"publishConfig": {
44+
"access": "public",
45+
"registry": "https://registry.npmjs.org"
46+
}
4347
}

0 commit comments

Comments
 (0)