#!/bin/bash
# DBeaver MCP Server Publish Script
# This script helps with publishing new versions to npm
set -e
echo "π DBeaver MCP Server - Publishing to npm"
echo "=========================================="
# Check if we're in the right directory
if [ ! -f "package.json" ]; then
echo "β Error: package.json not found. Please run this script from the project root."
exit 1
fi
# Check if git is clean
if [ -n "$(git status --porcelain)" ]; then
echo "β Error: Git working directory is not clean. Please commit all changes first."
echo "Current status:"
git status --short
exit 1
fi
# Check if logged into npm
if ! npm whoami > /dev/null 2>&1; then
echo "β Error: Not logged into npm. Please run 'npm login' first."
exit 1
fi
echo "β Git working directory is clean"
echo "β Logged into npm as: $(npm whoami)"
# Determine version type
if [ "$1" = "major" ]; then
VERSION_TYPE="major"
echo "π¦ Publishing MAJOR version"
elif [ "$1" = "minor" ]; then
VERSION_TYPE="minor"
echo "π¦ Publishing MINOR version"
else
VERSION_TYPE="patch"
echo "π¦ Publishing PATCH version"
fi
# Build and publish
echo "π¨ Building project..."
npm run build
echo "π€ Publishing to npm..."
# Use the direct npm publish command instead of the npm run publish script to avoid recursion
if [ "$VERSION_TYPE" = "major" ]; then
npm version major && npm publish
elif [ "$VERSION_TYPE" = "minor" ]; then
npm version minor && npm publish
else
npm version patch && npm publish
fi
echo ""
echo "π Successfully published dbeaver-mcp-server!"
echo "π Package info:"
npm info dbeaver-mcp-server version
echo ""
echo "π Install with: npm install -g dbeaver-mcp-server@latest"
echo "π View on npm: https://www.npmjs.com/package/dbeaver-mcp-server"