1+ #! /bin/bash
2+
3+ # Comprehensive release script for @drupaltools/mcp
4+ # This script will:
5+ # 1. Create a new version using standard-version
6+ # 2. Build the package
7+ # 3. Create and push git tag
8+ # 4. Publish to npm
9+
10+ set -e
11+
12+ echo " 🚀 Starting release process for @drupaltools/mcp"
13+
14+ # Check if we're on the main branch
15+ current_branch=$( git rev-parse --abbrev-ref HEAD)
16+ if [ " $current_branch " != " master" ]; then
17+ echo " ⚠️ Warning: You're not on the master branch (current: $current_branch )"
18+ read -p " Do you want to continue? (y/N): " -n 1 -r
19+ echo
20+ if [[ ! $REPLY =~ ^[Yy]$ ]]; then
21+ exit 1
22+ fi
23+ fi
24+
25+ # Check if working directory is clean
26+ if [ -n " $( git status --porcelain) " ]; then
27+ echo " ❌ Working directory is not clean. Please commit or stash changes first."
28+ exit 1
29+ fi
30+
31+ # Get the current version
32+ current_version=$( node -p " require('./package.json').version" )
33+ echo " 📍 Current version: $current_version "
34+
35+ # Determine release type
36+ release_type=" patch"
37+ if [ " $1 " = " minor" ] || [ " $1 " = " major" ]; then
38+ release_type=" $1 "
39+ fi
40+
41+ echo " 📦 Release type: $release_type "
42+
43+ # Run standard-version to update version and changelog
44+ echo " 📝 Updating version and changelog..."
45+ npm run release:$release_type
46+
47+ # Get the new version
48+ new_version=$( node -p " require('./package.json').version" )
49+ echo " 📍 New version: $new_version "
50+
51+ # Build the package
52+ echo " 🔨 Building package..."
53+ npm run build
54+
55+ # Add changes to git
56+ echo " 📤 Adding changes to git..."
57+ git add package.json RELEASES.md
58+ git commit -m " chore(release): $new_version "
59+
60+ # Create and push git tag
61+ echo " 🏷️ Creating git tag v$new_version ..."
62+ git tag -a " v$new_version " -m " Release $new_version "
63+
64+ echo " 📤 Pushing changes and tag to origin..."
65+ git push origin master
66+ git push origin " v$new_version "
67+
68+ # Ask if user wants to publish to npm
69+ read -p " 📦 Do you want to publish to npm now? (y/N): " -n 1 -r
70+ echo
71+ if [[ $REPLY =~ ^[Yy]$ ]]; then
72+ echo " 📦 Publishing to npm..."
73+ npm run publish:npm
74+ echo " ✅ Published to npm successfully!"
75+ else
76+ echo " 💡 To publish manually, run: npm run publish:npm"
77+ fi
78+
79+ echo " "
80+ echo " 🎉 Release $new_version completed successfully!"
81+ echo " 📋 Summary:"
82+ echo " - Version bumped from $current_version to $new_version "
83+ echo " - Changelog updated in RELEASES.md"
84+ echo " - Git tag v$new_version created and pushed"
85+ echo " - Package built and ready for distribution"
86+ echo " "
87+ echo " 🔗 View release: https://github.com/drupaltools/drupaltools.github.io/releases/tag/v$new_version "
88+ echo " 📦 npm package: https://www.npmjs.com/package/@drupaltools/mcp"
0 commit comments