@@ -23,50 +23,41 @@ concurrency:
2323 group : ${{ github.workflow }}-${{ github.sha }}
2424 cancel-in-progress : true
2525
26- # 定义工作流中的作业
2726jobs :
2827 build :
29- # 指定运行环境为最新版本的ubuntu
3028 runs-on : ubuntu-latest
3129 outputs :
3230 version : ${{ steps.ver.outputs.value }}
3331 steps :
34- # 步骤1: 检出代码
3532 - name : CheckOut Code
3633 uses : actions/checkout@v4
3734 with :
3835 ref : ${{ github.ref_name }}
3936
40- # 步骤2: 设置pnpm包管理器
4137 - name : Setup pnpm
4238 uses : pnpm/action-setup@v4
4339 with :
4440 version : 9
4541
46- # 步骤3: 设置Node.js环境
4742 - name : Setup Node
4843 uses : actions/setup-node@v4
4944 with :
50- node-version : 20 # 使用Node.js 20版本
51- registry-url : " https://registry.npmjs.org" # 设置npm registry地址
45+ node-version : 20
46+ registry-url : " https://registry.npmjs.org"
5247
53- # 步骤4: 获取pnpm缓存目录路径
5448 - name : Get pnpm store directory
5549 id : pnpm-cache
5650 run : |
5751 echo "pnpm_cache_dir=$(pnpm store path)" >> $GITHUB_OUTPUT
5852
59- # 步骤5: 配置pnpm缓存
6053 - uses : actions/cache@v3
6154 name : Setup pnpm cache
6255 with :
6356 path : ${{ steps.pnpm-cache.outputs.pnpm_cache_dir }}
64- # 使用操作系统类型和pnpm-lock.yaml的哈希值作为缓存键
6557 key : ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
6658 restore-keys : |
6759 ${{ runner.os }}-pnpm-store-
6860
69- # 步骤6: 安装项目依赖
7061 - name : Install dependencies
7162 run : pnpm i --no-frozen-lockfile
7263 - name : Get version
9687 find template -type d -name node_modules -prune -exec rm -rf {} +
9788 # 生成待发布 tarball(验证用)
9889 npm pack --dry-run
99- - name : Upload build artifact
100- uses : actions/upload-artifact@v4
101- with :
102- name : dist-artifact
103- path : ./
104- # Publish job
105- publish :
106- needs : build
107- runs-on : ubuntu-latest
108- steps :
109- - uses : actions/setup-node@v4
110- with :
111- node-version : 20
112- registry-url : https://registry.npmjs.org
113- - name : Download build artifact
114- uses : actions/download-artifact@v4
115- with :
116- name : dist-artifact
117- path : ./
11890 - name : Show version and tag
11991 run : |
12092 echo "publish version: ${{ needs.build.outputs.version }}"
0 commit comments