check if tag can really be created locally and remote

This commit is contained in:
2026-02-22 18:34:26 +01:00
parent 5bfca35773
commit fd27403f30
+19
View File
@@ -28,9 +28,28 @@ fi
CURRENT_MAJOR=${CURRENT_VERSION#v} CURRENT_MAJOR=${CURRENT_VERSION#v}
if ! [[ "$CURRENT_VERSION" =~ ^v[0-9]+$ ]]; then
echo "Error: Invalid version format in $VERSION_FILE. Expected v0, v1, v2, etc."
exit 1
fi
NEXT_VERSION=$((CURRENT_MAJOR + 1)) NEXT_VERSION=$((CURRENT_MAJOR + 1))
NEXT_VERSION_STR="v$NEXT_VERSION" NEXT_VERSION_STR="v$NEXT_VERSION"
if git rev-parse "refs/tags/$NEXT_VERSION_STR" >/dev/null 2>&1; then
echo "Error: Tag $NEXT_VERSION_STR already exists locally."
exit 1
fi
if git remote get-url origin >/dev/null 2>&1; then
if git ls-remote --tags origin "$NEXT_VERSION_STR" 2>/dev/null | grep -q "$NEXT_VERSION_STR"; then
echo "Error: Tag $NEXT_VERSION_STR already exists on remote."
exit 1
fi
else
echo "Warning: No remote configured. You can still create the release locally."
fi
echo "Current version: $CURRENT_VERSION" echo "Current version: $CURRENT_VERSION"
echo "Proposed version: $NEXT_VERSION_STR" echo "Proposed version: $NEXT_VERSION_STR"
echo "" echo ""