File tree Expand file tree Collapse file tree 2 files changed +27
-21
lines changed
Expand file tree Collapse file tree 2 files changed +27
-21
lines changed Original file line number Diff line number Diff line change 77 tags :
88 - v*
99
10+ # 权限
11+ permissions :
12+ id-token : write
13+ contents : write
14+
1015# 工作流执行的任务
1116jobs :
1217 build-and-publish :
1318 # 任务运行的虚拟机环境
1419 runs-on : ubuntu-latest
20+
21+ # 启用手动发布审批,需在 GitHub "Settings > Environments" 中配置。
22+ # 此名称 ('npm-publish') 必须与 npm Provenance 设置中的环境名完全一致。
23+ environment : npm-publish
24+
1525
1626 steps :
17- # 第一步: 检出仓库代码
27+ # 检出仓库代码
1828 - name : Checkout repository
1929 uses : actions/checkout@v4
2030 with :
2131 fetch-depth : 0
2232
23- # 第二步: 安装 pnpm
33+ # 安装 pnpm
2434 - name : Set up pnpm
2535 uses : pnpm/action-setup@v4
2636 with :
2737 # 指定你项目使用的 pnpm 版本
2838 version : 10.15.1
2939
30- # 第三步: 设置 Node.js 环境 (在 pnpm 之后)
40+ # 设置 Node.js 环境 (在 pnpm 之后)
3141 - name : Set up Node.js
3242 uses : actions/setup-node@v4
3343 with :
3444 node-version : ' 22.13.0'
3545 # 关键:为 pnpm 设置缓存
3646 cache : ' pnpm'
3747
38- # 第四步: 安装依赖
48+ # 安装依赖
3949 - name : Install dependencies
4050 run : pnpm install --frozen-lockfile
4151
42- # 第五步: 校验版本号是否一致 (这一步无需任何改动)
52+ # 校验版本号是否一致 (这一步无需任何改动)
4353 - name : Check version match
4454 run : |
4555 TAG_VERSION=$(echo ${{ github.ref_name }} | sed 's/^v//')
@@ -53,23 +63,16 @@ jobs:
5363 exit 1
5464 fi
5565
56- # 第六步: 构建项目 (如果需要)
66+ # 构建项目
5767 - name : Build project
5868 run : pnpm build
5969
60- # 第七步:配置 npm Registry (为了发布)
61- - name : Configure npm registry
62- run : pnpm config set //registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}
6370
64- # 第八步: 发布到 npm
71+ # 发布到 npm
6572 - name : Publish to npm
6673 run : pnpm publish --no-git-checks
67- env :
68- # 这一行其实在 pnpm v7+ 中已经不是必需的了,因为上面的 config set 已经完成了认证
69- # 但保留它也无害,可以兼容旧版本
70- NODE_AUTH_TOKEN : ${{ secrets.NPM_TOKEN }}
7174
72- # 第九步: 生成 changelog
75+ # 生成 changelog
7376 - run : pnpm dlx changelogithub --no-group
7477 continue-on-error : true
7578 env :
Original file line number Diff line number Diff line change 1212 required : true
1313 type : string
1414
15+ # 权限
16+ permissions :
17+ contents : write
18+
19+
1520jobs :
1621 regenerate :
1722 runs-on : ubuntu-latest
1823 steps :
19- # 步骤 1: 检出代码
24+ # 检出代码
2025 # 确保检出的是你手动输入的那个特定的标签
2126 - name : Checkout specific tag
2227 uses : actions/checkout@v4
2631 # 检出你通过输入框传入的标签
2732 ref : ${{ github.event.inputs.tagName }}
2833
29- # 步骤 2: (可选) 安装 Node.js 和 pnpm
34+ # 安装 Node.js 和 pnpm
3035 # 如果你的 changelog 生成依赖于项目中的某些开发依赖,则需要此步骤
3136 - name : Set up pnpm
3237 uses : pnpm/action-setup@v4
3944 node-version : ' 22.13.0'
4045 cache : ' pnpm'
4146
42- # 如果 changelogithub 是项目的 devDependency,你可能需要安装它
43- # - name: Install dependencies
44- # run: pnpm install --frozen-lockfile
4547
46- # 步骤 3: 重新生成 Changelog
48+
49+ # 重新生成 Changelog
4750 # 这一步会为当前检出的标签(即你输入的标签)创建或更新 GitHub Release
4851 - name : Generate changelog
4952 run : pnpm dlx changelogithub --no-group
You can’t perform that action at this time.
0 commit comments