Merge pull request #205 from richardrigutins/overwrite-tag

[Chore] Update release script to check for and overwrite existing tags
This commit is contained in:
Riccardo Rigutini 2024-09-29 18:36:36 +02:00 committed by GitHub
commit 7ec73a0d94
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 25 additions and 2 deletions

27
script/release Normal file → Executable file
View File

@ -11,8 +11,9 @@
#
# 1. Get the latest release tag
# 2. Prompt the user for a new release tag
# 3. Tag the new release
# 4. Push the new tag to the remote
# 3. Check if the tag exists and ask for confirmation to overwrite
# 4. Tag the new release
# 5. Push the new tag to the remote
#
# Usage:
#
@ -49,6 +50,28 @@ else
exit 1
fi
# Check if the tag exists; if it does, ask the user for confirmation to overwrite
if git rev-parse -q --verify "refs/tags/$new_tag" >/dev/null; then
read -r -p "The tag already exists. Overwrite? [y/N] " response
if [[ ! "$response" =~ ^([yY][eE][sS]|[yY])$ ]]; then
echo -e "${RED}Aborted${OFF}"
exit 1
else
# Delete the tag locally
git tag -d "$new_tag"
echo -e "${GREEN}Deleted local tag: $new_tag${OFF}"
# Delete the tag remotely
git push origin --delete "$new_tag"
echo -e "${GREEN}Deleted remote tag: $new_tag${OFF}"
fi
else
read -r -p "The tag does not exist and will be created. Continue? [y/N] " response
if [[ ! "$response" =~ ^([yY][eE][sS]|[yY])$ ]]; then
echo -e "${RED}Aborted${OFF}"
exit 1
fi
fi
# Tag the new release
git tag -a "$new_tag" -m "$new_tag Release"
echo -e "${GREEN}Tagged: $new_tag${OFF}"