Skip to content

Commit

Permalink
Merge pull request #61 from Zhaopudark/dev
Browse files Browse the repository at this point in the history
Prepare for publish
  • Loading branch information
Zhaopudark authored Jan 19, 2024
2 parents 8eb81aa + 4e25b97 commit fb0336b
Showing 1 changed file with 24 additions and 22 deletions.
46 changes: 24 additions & 22 deletions Scripts/tag_and_push.ps1
Original file line number Diff line number Diff line change
@@ -1,24 +1,26 @@
$currentBranch = git rev-parse --abbrev-ref HEAD
if ($currentBranch -eq "main") {
$version = . "${PSScriptRoot}/check_release_version.ps1"
$tagName = "v${version}"
# 检测标签是否存在
if (git show-ref "refs/tags/$tagName") {
Write-Error "Tag '$tagName' already exists."
} else {
# 标签不存在
Write-Output "Tag '$tagName' does not exist."
Write-Output "Creating tag '$tagName'."
git tag -a $tagName -m "Release $tagName"
}

$version = . "${PSScriptRoot}/check_release_version.ps1"
$tagName = "v${version}"

# 检测标签是否存在
if (git show-ref "refs/tags/$tagName") {
Write-Error "Tag '$tagName' already exists."
} else {
# 标签不存在
Write-Output "Tag '$tagName' does not exist."
Write-Output "Creating tag '$tagName'."
git tag -a $tagName -m "Release $tagName"
}

# 检测远程标签是否存在
if (git ls-remote --tags origin | Where-Object { $_ -match "refs/tags/$tagName" }) {
Write-Error "Remote tag '$tagName' already exists."
# 检测远程标签是否存在
if (git ls-remote --tags origin | Where-Object { $_ -match "refs/tags/$tagName" }) {
Write-Error "Remote tag '$tagName' already exists."
} else {
# 远程标签不存在
Write-Output "Remote tag '$tagName' does not exist."
Write-Output "Pushing tag '$tagName' to remote."
git push origin $tagName
}
} else {
# 远程标签不存在
Write-Output "Remote tag '$tagName' does not exist."
Write-Output "Pushing tag '$tagName' to remote."
git push origin $tagName
}

Write-Host "Not on main branch. Current branch: $currentBranch"
}

0 comments on commit fb0336b

Please sign in to comment.