When creating a release tag, follow these steps:
Determine the version: If the user provided a version (e.g.
v0.2.0), use it directly. Otherwise, rungit tag --list 'v*' --sort=-version:refname | head -5to show recent tags, then ask the user for the new version.Validate the tag format: The tag must match
v[0-9]+.[0-9]+.[0-9]+(e.g.v1.2.3). Reject anything that does not match and ask for a valid version.Ensure the current branch is main: Run
git branch --show-currentand verify the result ismain. If not, stop and tell the user that release tags must be created from themainbranch.Check for conflicts: Run
git tag -l <tag>to confirm the tag does not already exist locally, andgit ls-remote --tags origin <tag>to confirm it does not exist on the remote. If it exists, warn the user and stop.Confirm before acting: Show the user the tag name and the commit it will point to (
git rev-parse --short HEAD), then ask for confirmation before proceeding.Create and push the tag:
git tag <tag> git push origin <tag>Report the result: Confirm the tag was pushed and remind the user that the CD workflow will now run on GitHub Actions to build and publish the release.
To delete a tag and re-push (if the user asks to redo or fix a tag):
git tag -d <tag>
git push origin :refs/tags/<tag>
Then repeat steps 5–7.