Skip to content

Commit ec48608

Browse files
author
Your Name
committed
updated uplaod script
1 parent 92a7ff8 commit ec48608

File tree

1 file changed

+21
-3
lines changed

1 file changed

+21
-3
lines changed

scripts/release.ps1

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,12 +72,30 @@ try {
7272
Exec "python -m pip install --upgrade build twine"
7373
Exec "python -m build"
7474

75+
# Ensure branch exists locally; fall back to current branch if not
76+
& git show-ref --verify --quiet "refs/heads/$Branch" 2>$null
77+
if ($LASTEXITCODE -ne 0) {
78+
$currentBranch = (git rev-parse --abbrev-ref HEAD)
79+
Write-Host "Branch '$Branch' not found locally; using current branch '$currentBranch' instead."
80+
$Branch = $currentBranch
81+
}
82+
7583
# Push branch
7684
Exec "git push origin $Branch"
7785

78-
# Create annotated tag and push it
79-
Exec "git tag -a $Tag -m \"$Message\""
80-
Exec "git push origin $Tag"
86+
# Create annotated tag and push it (handle existing tags when -Force)
87+
& git rev-parse -q --verify "refs/tags/$Tag" > $null 2>&1
88+
if ($LASTEXITCODE -eq 0) {
89+
if ($Force) {
90+
Exec "git tag -f -a $Tag -m \"$Message\""
91+
Exec "git push -f origin $Tag"
92+
} else {
93+
throw "Tag $Tag already exists locally. Use -Force to overwrite."
94+
}
95+
} else {
96+
Exec "git tag -a $Tag -m \"$Message\""
97+
Exec "git push origin $Tag"
98+
}
8199

82100
# Upload to PyPI using twine and PYPI_API_TOKEN
83101
if (-not $env:PYPI_API_TOKEN) {

0 commit comments

Comments
 (0)