Skip to content

Commit 3020909

Browse files
author
Tenny
committed
chore: 增加提交发布脚本
Signed-off-by: Tenny <tenny.shu@foxmail.com>
1 parent c8f1667 commit 3020909

File tree

2 files changed

+26
-3
lines changed

2 files changed

+26
-3
lines changed

package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@
99
"docs:dev": "vitepress dev docs",
1010
"docs:build": "vitepress build docs",
1111
"docs:preview": "vitepress preview docs",
12-
"inspect:eslint": "eslint --inspect-config"
12+
"inspect:eslint": "eslint --inspect-config",
13+
"push": "pwsh scripts/publish.ps1 push",
14+
"publish": "./scripts/publish.ps1 publish"
1315
},
1416
"devDependencies": {
1517
"@types/node": "^22.3.0",

scripts/publish.ps1

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,27 @@
1-
param ($Cmd = $(throw "Command parameter is required."))
1+
param ($Cmd = $(throw "命令参数为必传参数."))
22

33
if ($Cmd -eq "push") {
4-
Write-Host "push..."
4+
$Message = Read-Host "请输入提交信息(`,`分隔多行)"
5+
6+
if ($Message -eq "") {
7+
Write-Host "提交信息不能为空" -ForegroundColor Red
8+
exit 1
9+
}
10+
11+
# 2. 将逗号替换为换行符
12+
$Message = $Message -replace ",", "`n"
13+
14+
# 提交到 dev 分支, 然后 squash 合并并提交到 main 分支
15+
git add .
16+
git commit -m $Message
17+
git push origin dev
18+
git checkout main
19+
git merge --squash dev
20+
git commit --no-edit
21+
git merge dev -m "new version"
22+
git push origin main
23+
24+
Write-Host $Message
525
} elseif (($Cmd -eq "pull") -or ($Cmd -eq "publish")) {
626
git pull origin main
727
pnpm lib:build
@@ -10,4 +30,5 @@ if ($Cmd -eq "push") {
1030
git merge main
1131

1232
Write-Host " "
33+
Write-Host "publish success" -ForegroundColor Green
1334
}

0 commit comments

Comments
 (0)