Skip to content

Commit 7a9c5c8

Browse files
committed
use pnpm
1 parent 66db286 commit 7a9c5c8

2 files changed

Lines changed: 31 additions & 12 deletions

File tree

.github/workflows/release.yml

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ on:
55
tags:
66
- 'v*' # 当推送以 'v' 开头的标签时触发
77

8+
permissions:
9+
contents: write # 给 release 创建权限
10+
811
jobs:
912
release:
1013
runs-on: ubuntu-latest
@@ -13,43 +16,50 @@ jobs:
1316
- name: Checkout code
1417
uses: actions/checkout@v4
1518
with:
16-
fetch-depth: 0 # 获取完整的git历史,包括标签
19+
fetch-depth: 0
20+
21+
- name: Setup pnpm
22+
uses: pnpm/action-setup@v3
23+
with:
24+
version: 10.14.0
25+
run_install: false
1726

1827
- name: Setup Node.js
1928
uses: actions/setup-node@v4
2029
with:
2130
node-version: '18'
22-
cache: 'npm'
31+
cache: 'pnpm'
2332

2433
- name: Install dependencies
25-
run: npm ci
34+
run: pnpm install --frozen-lockfile
2635

2736
- name: Run convert-changelog script
2837
run: node scripts/convert-changelog.js
2938
env:
30-
GITHUB_ACTIONS: 'true' # 告诉脚本这是在GitHub Actions环境中运行
39+
GITHUB_ACTIONS: 'true'
3140

3241
- name: Create Release
3342
uses: actions/create-release@v1
3443
env:
3544
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
3645
with:
37-
tag_name: ${{ github.ref }}
38-
release_name: Release ${{ github.ref }}
46+
# github.ref 格式是 refs/tags/v1.0.0,需要提取 tag 名
47+
tag_name: ${{ github.ref_name }}
48+
release_name: Release ${{ github.ref_name }}
3949
body: |
4050
## 变更日志
4151
4252
请查看 [CHANGELOG](CHANGELOG) 文件了解详细变更内容。
4353
4454
## 下载
4555
46-
- [Source code (zip)](https://github.com/${{ github.repository }}/archive/${{ github.ref }}.zip)
47-
- [Source code (tar.gz)](https://github.com/${{ github.repository }}/archive/${{ github.ref }}.tar.gz)
56+
- [Source code (zip)](https://github.com/${{ github.repository }}/archive/${{ github.ref_name }}.zip)
57+
- [Source code (tar.gz)](https://github.com/${{ github.repository }}/archive/${{ github.ref_name }}.tar.gz)
4858
draft: false
4959
prerelease: false
5060

5161
- name: Build project
52-
run: npm run build
62+
run: pnpm run build
5363

5464
- name: Upload build artifacts
5565
uses: actions/upload-artifact@v4

.github/workflows/version-manager.yml

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,22 @@ jobs:
1515
uses: actions/checkout@v4
1616
with:
1717
token: ${{ secrets.GITHUB_TOKEN }}
18-
fetch-depth: 0
18+
fetch-depth: 0 # 获取完整历史,方便切换分支
19+
20+
- name: Setup pnpm
21+
uses: pnpm/action-setup@v3
22+
with:
23+
version: 10.14.0
24+
run_install: false
1925

2026
- name: Setup Node.js
2127
uses: actions/setup-node@v4
2228
with:
2329
node-version: '18'
30+
cache: 'pnpm'
2431

2532
- name: Install dependencies
26-
run: npm ci
33+
run: pnpm install --frozen-lockfile
2734

2835
- name: Run convert-changelog script
2936
run: node scripts/convert-changelog.js
@@ -34,9 +41,11 @@ jobs:
3441
run: |
3542
git config --local user.email "action@github.com"
3643
git config --local user.name "GitHub Action"
44+
git checkout main # 切换到主分支
3745
git add .
46+
# 只有有改动才 commit
3847
git diff --quiet && git diff --staged --quiet || git commit -m "chore: update version files for ${{ github.ref_name }}"
39-
git push
48+
git push origin main # 推送到主分支
4049
4150
- name: Show version statistics
4251
run: |

0 commit comments

Comments
 (0)