#!/bin/bash
echo "๐ Publishing SwiftOpenAI MCP Server to npm"
echo "=========================================="
# Check if logged in to npm
npm whoami &> /dev/null
if [ $? -ne 0 ]; then
echo "โ Not logged in to npm. Please run: npm login"
exit 1
fi
# Check if we have a clean working directory
if [[ -n $(git status -s) ]]; then
echo "โ Working directory is not clean. Please commit changes first."
exit 1
fi
# Build release binary
echo "๐ฆ Building release binary..."
swift build -c release
if [ $? -ne 0 ]; then
echo "โ Build failed"
exit 1
fi
# Prepare distribution
echo "๐ Preparing distribution..."
npm run prepare-dist
# Run tests
echo "๐งช Running tests..."
npm test 2>/dev/null || echo "โน๏ธ No tests configured"
# Show what will be published
echo ""
echo "๐ฆ Package contents:"
npm pack --dry-run
echo ""
echo "Ready to publish version $(node -p "require('./package.json').version")"
echo "This will publish to: swiftopenai-mcp"
echo ""
read -p "Continue? (y/N) " -n 1 -r
echo ""
if [[ ! $REPLY =~ ^[Yy]$ ]]; then
echo "โ Publish cancelled"
exit 1
fi
# Publish to npm
echo "๐ Publishing to npm..."
npm publish --access public
if [ $? -eq 0 ]; then
echo ""
echo "โ Successfully published!"
echo "๐ฆ View at: https://www.npmjs.com/package/swiftopenai-mcp"
echo ""
echo "๐ท๏ธ Don't forget to:"
echo " 1. Create a git tag: git tag v$(node -p "require('./package.json').version")"
echo " 2. Push the tag: git push origin v$(node -p "require('./package.json').version")"
echo " 3. Create a GitHub release"
else
echo "โ Publish failed"
exit 1
fi