File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -10,18 +10,27 @@ TAG="v$VERSION"
1010echo " Detected package version: $VERSION "
1111echo " Target tag: $TAG "
1212
13- # Check if tag already exists locally
14- if git rev-parse " $TAG " > /dev/null 2>&1 ; then
15- echo " Error: Tag $TAG already exists locally."
16- echo " Please bump the version in package.json before releasing."
17- exit 1
13+ # Check if tag already exists (locally or remote)
14+ TAG_EXISTS=false
15+ if git rev-parse " $TAG " > /dev/null 2>&1 || git ls-remote origin " refs/tags/$TAG " | grep -q " $TAG " ; then
16+ TAG_EXISTS=true
1817fi
1918
20- # Check if tag already exists on remote
21- if git ls-remote origin " refs/tags/$TAG " | grep -q " $TAG " ; then
22- echo " Error: Tag $TAG already exists on remote origin."
23- echo " Please bump the version in package.json before releasing."
24- exit 1
19+ if [ " $TAG_EXISTS " = true ]; then
20+ echo " ⚠️ Tag $TAG already exists."
21+ echo " To re-release this version, we need to delete the existing tag."
22+ read -p " Do you want to delete the existing tag and re-release? (y/N) " -n 1 -r
23+ echo " "
24+ if [[ ! $REPLY =~ ^[Yy]$ ]]; then
25+ echo " Cancelled."
26+ exit 1
27+ fi
28+
29+ echo " Deleting local tag..."
30+ git tag -d " $TAG " || true
31+
32+ echo " Deleting remote tag..."
33+ git push origin :refs/tags/$TAG || true
2534fi
2635
2736echo " "
You can’t perform that action at this time.
0 commit comments