Skip to content

Commit 23aa1a1

Browse files
committed
feat: Allow re-releasing a version by prompting to delete existing local and remote tags instead of exiting.
1 parent 59086db commit 23aa1a1

1 file changed

Lines changed: 19 additions & 10 deletions

File tree

scripts/publish-release.sh

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,18 +10,27 @@ TAG="v$VERSION"
1010
echo "Detected package version: $VERSION"
1111
echo "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
1817
fi
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
2534
fi
2635

2736
echo ""

0 commit comments

Comments
 (0)