Skip to content

Commit 60a60c0

Browse files
jnnsbrrjnnsbrr
authored andcommitted
improve workflow
1 parent 68d08a9 commit 60a60c0

1 file changed

Lines changed: 18 additions & 8 deletions

File tree

pycoupler/release.py

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -143,8 +143,8 @@ def run_command(cmd, description, fail_on_error=True):
143143

144144

145145
def delete_tag_if_exists(tag_name):
146-
"""Delete a tag locally if it exists. Remote tags are handled during manual push."""
147-
print(f"Checking if tag {tag_name} already exists locally...")
146+
"""Delete a tag locally and remotely if it exists."""
147+
print(f"Checking if tag {tag_name} already exists...")
148148

149149
# Check if tag exists locally (fast)
150150
try:
@@ -163,8 +163,20 @@ def delete_tag_if_exists(tag_name):
163163
except (subprocess.CalledProcessError, subprocess.TimeoutExpired):
164164
print(f"Tag {tag_name} does not exist locally")
165165

166-
print(f"Local tag {tag_name} cleanup completed.")
167-
print("Note: Remote tags will be handled when you manually push with --tags")
166+
# Always try to delete remote tag (in case it exists)
167+
print(f"Deleting remote tag {tag_name} (if it exists)...")
168+
try:
169+
run_command(
170+
f"git push origin :refs/tags/{tag_name}",
171+
f"Deleting remote tag {tag_name}",
172+
fail_on_error=False # Don't fail if tag doesn't exist remotely
173+
)
174+
except Exception:
175+
# Ignore errors - tag might not exist remotely
176+
pass
177+
178+
print(f"Tag {tag_name} cleanup completed.")
179+
print("Note: You can now push your new commit and tag manually with: git push origin <branch> --tags")
168180

169181

170182
def update_citation_file(version, date=None):
@@ -360,10 +372,8 @@ def main():
360372
print("To push to repository, run:")
361373
print(f" git push origin {current_branch} --tags")
362374
print("")
363-
print("Note: If this is a re-release and the tag exists remotely,")
364-
print("you may need to force push the tag:")
365-
print(f" git push origin :refs/tags/v{version} # Delete remote tag")
366-
print(f" git push origin v{version} # Push new tag")
375+
print("Note: Remote tag has been automatically deleted if it existed.")
376+
print("You can now safely push your new commit and tag together.")
367377
print("")
368378
print("The CI pipeline will automatically:")
369379
print(" - Run tests with pytest and coverage")

0 commit comments

Comments
 (0)