#!/usr/bin/env node
import { readFileSync } from 'fs';
import { execSync } from 'child_process';
// 读取package.json获取版本号
const packageJson = JSON.parse(readFileSync('./package.json', 'utf8'));
const version = packageJson.version;
console.log(`🚀 准备发布 Yuque MCP Server v${version}`);
// 检查是否已构建
try {
execSync('test -d dist', { stdio: 'inherit' });
console.log('✅ 构建文件已存在');
} catch {
console.log('🔨 正在构建项目...');
execSync('npm run build', { stdio: 'inherit' });
}
// 检查Git状态
try {
execSync('git diff --exit-code', { stdio: 'inherit' });
console.log('✅ Git工作区干净');
} catch {
console.log('❌ Git工作区有未提交的更改,请先提交');
process.exit(1);
}
// 创建Git标签
const tag = `v${version}`;
console.log(`🏷️ 创建Git标签: ${tag}`);
execSync(`git tag -a ${tag} -m "Release ${tag}"`, { stdio: 'inherit' });
console.log(`\n🎉 发布准备完成!`);
console.log(`\n📋 下一步操作:`);
console.log(`1. 推送到GitHub: git push origin main --tags`);
console.log(`2. 在GitHub上创建Release: https://github.com/YOUR_USERNAME/yuque-mcp-server/releases/new`);
console.log(`3. 使用标签: ${tag}`);
console.log(`4. 复制RELEASE_NOTES.md的内容作为Release描述`);