|
|
@@ -220,9 +220,20 @@ function gitCommit(version) {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-// Git 添加 tag
|
|
|
+// Git 添加 tag(如果已存在则先删除)
|
|
|
function gitTag(version) {
|
|
|
try {
|
|
|
+ // 先尝试删除已存在的 tag
|
|
|
+ try {
|
|
|
+ execSync(`git tag -d v${version}`, {
|
|
|
+ encoding: 'utf-8',
|
|
|
+ stdio: 'pipe'
|
|
|
+ })
|
|
|
+ console.log(`[提示] 已删除旧 tag: v${version}`)
|
|
|
+ } catch {
|
|
|
+ // tag 不存在,忽略错误
|
|
|
+ }
|
|
|
+ // 添加新 tag
|
|
|
execSync(`git tag v${version}`, {
|
|
|
encoding: 'utf-8',
|
|
|
stdio: 'inherit'
|
|
|
@@ -236,6 +247,10 @@ function gitTag(version) {
|
|
|
// Git 推送(包含 tags)
|
|
|
function gitPush() {
|
|
|
try {
|
|
|
+ // 确保终端处于正常模式,以便 git 可以进行交互
|
|
|
+ if (process.stdin.isTTY) {
|
|
|
+ process.stdin.setRawMode(false)
|
|
|
+ }
|
|
|
execSync('git push --follow-tags', {
|
|
|
encoding: 'utf-8',
|
|
|
stdio: 'inherit'
|