Skip to content

Commit

Permalink
Prepare for publish
Browse files Browse the repository at this point in the history
  • Loading branch information
Zhaopudark committed Jan 19, 2024
1 parent 8eb81aa commit 4e25b97
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 4e25b97

Please sign in to comment.