File tree Expand file tree Collapse file tree 1 file changed +21
-3
lines changed
Expand file tree Collapse file tree 1 file changed +21
-3
lines changed Original file line number Diff line number Diff 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 ) {
You can’t perform that action at this time.
0 commit comments