Skip to content

Commit

Permalink
chore: 增加提交发布脚本
Browse files Browse the repository at this point in the history
Signed-off-by: Tenny <tenny.shu@foxmail.com>
  • Loading branch information
Tenny committed Aug 16, 2024
1 parent c8f1667 commit 3020909
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 3 deletions.
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@
"docs:dev": "vitepress dev docs",
"docs:build": "vitepress build docs",
"docs:preview": "vitepress preview docs",
"inspect:eslint": "eslint --inspect-config"
"inspect:eslint": "eslint --inspect-config",
"push": "pwsh scripts/publish.ps1 push",
"publish": "./scripts/publish.ps1 publish"
},
"devDependencies": {
"@types/node": "^22.3.0",
Expand Down
25 changes: 23 additions & 2 deletions scripts/publish.ps1
Original file line number Diff line number Diff line change
@@ -1,7 +1,27 @@
param ($Cmd = $(throw "Command parameter is required."))
param ($Cmd = $(throw "命令参数为必传参数."))

if ($Cmd -eq "push") {
Write-Host "push..."
$Message = Read-Host "请输入提交信息(`,`分隔多行)"

if ($Message -eq "") {
Write-Host "提交信息不能为空" -ForegroundColor Red
exit 1
}

# 2. 将逗号替换为换行符
$Message = $Message -replace ",", "`n"

# 提交到 dev 分支, 然后 squash 合并并提交到 main 分支
git add .
git commit -m $Message
git push origin dev
git checkout main
git merge --squash dev
git commit --no-edit
git merge dev -m "new version"
git push origin main

Write-Host $Message
} elseif (($Cmd -eq "pull") -or ($Cmd -eq "publish")) {
git pull origin main
pnpm lib:build
Expand All @@ -10,4 +30,5 @@ if ($Cmd -eq "push") {
git merge main

Write-Host " "
Write-Host "publish success" -ForegroundColor Green
}

0 comments on commit 3020909

Please sign in to comment.