#!/usr/bin/env node
import { execSync } from 'child_process';
import fs from 'fs';
import path from 'path';
const versionType = process.argv[2] || 'patch'; // patch, minor, major
if (!['patch', 'minor', 'major'].includes(versionType)) {
console.error('β Invalid version type. Use: patch, minor, or major');
process.exit(1);
}
console.log(`π Creating ${versionType} release...`);
try {
// 1. Update version in package.json
console.log('π¦ Updating version...');
execSync(`npm version ${versionType}`, { stdio: 'inherit' });
// 2. Build the project
console.log('π¨ Building project...');
execSync('npm run build', { stdio: 'inherit' });
// 3. Run tests
console.log('π§ͺ Running tests...');
execSync('npm test', { stdio: 'inherit' });
// 4. Get the new version
const packageJson = JSON.parse(fs.readFileSync('package.json', 'utf8'));
const newVersion = packageJson.version;
// 5. Create git tag
console.log(`π·οΈ Creating git tag v${newVersion}...`);
execSync(`git tag v${newVersion}`, { stdio: 'inherit' });
// 6. Push changes and tags
console.log('π€ Pushing changes and tags...');
execSync('git push', { stdio: 'inherit' });
execSync('git push --tags', { stdio: 'inherit' });
// 7. Publish to NPM (using GitHub Actions)
console.log('π¦ Publishing to NPM via GitHub Actions...');
console.log(' Note: Publishing will be handled by the automated workflow');
// 8. Create GitHub release
console.log('π Creating GitHub release...');
const releaseNotes = generateReleaseNotes(newVersion, versionType);
execSync(`gh release create v${newVersion} --title "Sociona MCP Server v${newVersion}" --notes "${releaseNotes}"`, { stdio: 'inherit' });
console.log(`β
Successfully released v${newVersion}!`);
console.log(`π¦ NPM: https://www.npmjs.com/package/sociona-mcp-server`);
console.log(`π GitHub: https://github.com/fav-devs/sociona-mcp-server/releases/tag/v${newVersion}`);
} catch (error) {
console.error('β Release failed:', error.message);
process.exit(1);
}
function generateReleaseNotes(version, type) {
const features = [
'Complete MCP server implementation for Sociona social media API',
'Support for X (Twitter), Instagram, and Threads',
'CLI tool for easy execution (`sociona-mcp`)',
'Comprehensive documentation and installation guides'
];
const changes = {
major: 'π Major release with breaking changes and new features',
minor: 'β¨ New features and improvements',
patch: 'π Bug fixes and minor improvements'
};
return `## ${changes[type]}
### Features
${features.map(f => `- ${f}`).join('\n')}
### Installation
\`\`\`bash
npm install -g sociona-mcp-server
\`\`\`
### What's New
- β
Publish posts immediately
- β
Schedule posts for future publication
- β
Cancel scheduled posts
- β
List connected social accounts
- β
Retrieve post history and analytics
- β
Multi-platform support (X, Instagram, Threads)
- β
CLI tool for easy execution
- β
Comprehensive documentation
### Documentation
- [Installation Guide](https://github.com/fav-devs/sociona-mcp-server#installation)
- [Usage Examples](https://github.com/fav-devs/sociona-mcp-server#usage)
- [Developer Setup](https://github.com/fav-devs/sociona-mcp-server/blob/main/DEVELOPER_INSTALLATION.md)
### Links
- [NPM Package](https://www.npmjs.com/package/sociona-mcp-server)
- [GitHub Repository](https://github.com/fav-devs/sociona-mcp-server)`;
}