diff --git a/.releaserc.json b/.releaserc.json index b5154bae..6d214050 100644 --- a/.releaserc.json +++ b/.releaserc.json @@ -5,10 +5,11 @@ "@semantic-release/release-notes-generator", "@semantic-release/changelog", "@semantic-release/npm", + "./tools/semantic-release-sync-installer.js", [ "@semantic-release/git", { - "assets": ["package.json", "package-lock.json", "CHANGELOG.md"], + "assets": ["package.json", "package-lock.json", "tools/installer/package.json", "CHANGELOG.md"], "message": "chore(release): ${nextRelease.version} [skip ci]\n\n${nextRelease.notes}" } ], diff --git a/tools/semantic-release-sync-installer.js b/tools/semantic-release-sync-installer.js new file mode 100644 index 00000000..3a5f3e6b --- /dev/null +++ b/tools/semantic-release-sync-installer.js @@ -0,0 +1,31 @@ +/** + * Semantic-release plugin to sync installer package.json version + */ + +const fs = require('fs'); +const path = require('path'); + +function prepare(pluginConfig, context) { + const { nextRelease, logger } = context; + + // Path to installer package.json + const installerPackagePath = path.join(process.cwd(), 'tools', 'installer', 'package.json'); + + if (!fs.existsSync(installerPackagePath)) { + logger.log('Installer package.json not found, skipping sync'); + return; + } + + // Read installer package.json + const installerPackage = JSON.parse(fs.readFileSync(installerPackagePath, 'utf8')); + + // Update version + installerPackage.version = nextRelease.version; + + // Write back + fs.writeFileSync(installerPackagePath, JSON.stringify(installerPackage, null, 2) + '\n'); + + logger.log(`Synced installer package.json to version ${nextRelease.version}`); +} + +module.exports = { prepare }; \ No newline at end of file diff --git a/tools/sync-installer-version.js b/tools/sync-installer-version.js new file mode 100644 index 00000000..e994c50f --- /dev/null +++ b/tools/sync-installer-version.js @@ -0,0 +1,34 @@ +#!/usr/bin/env node + +/** + * Sync installer package.json version with main package.json + * Used by semantic-release to keep versions in sync + */ + +const fs = require('fs'); +const path = require('path'); + +function syncInstallerVersion() { + // Read main package.json + const mainPackagePath = path.join(__dirname, '..', 'package.json'); + const mainPackage = JSON.parse(fs.readFileSync(mainPackagePath, 'utf8')); + + // Read installer package.json + const installerPackagePath = path.join(__dirname, 'installer', 'package.json'); + const installerPackage = JSON.parse(fs.readFileSync(installerPackagePath, 'utf8')); + + // Update installer version to match main version + installerPackage.version = mainPackage.version; + + // Write back installer package.json + fs.writeFileSync(installerPackagePath, JSON.stringify(installerPackage, null, 2) + '\n'); + + console.log(`Synced installer version to ${mainPackage.version}`); +} + +// Run if called directly +if (require.main === module) { + syncInstallerVersion(); +} + +module.exports = { syncInstallerVersion }; \ No newline at end of file diff --git a/tools/version-bump.js b/tools/version-bump.js index f569cdc6..e24142c5 100755 --- a/tools/version-bump.js +++ b/tools/version-bump.js @@ -33,38 +33,18 @@ async function bumpVersion(type = 'patch') { process.exit(1); } - console.log(chalk.blue(`🔄 Bumping ${type} version...`)); + console.log(chalk.yellow('⚠️ Manual version bumping is disabled.')); + console.log(chalk.blue('🤖 This project uses semantic-release for automated versioning.')); + console.log(''); + console.log(chalk.bold('To create a new release, use conventional commits:')); + console.log(chalk.cyan(' feat: new feature (minor version bump)')); + console.log(chalk.cyan(' fix: bug fix (patch version bump)')); + console.log(chalk.cyan(' feat!: breaking change (major version bump)')); + console.log(''); + console.log(chalk.dim('Example: git commit -m "feat: add new installer features"')); + console.log(chalk.dim('Then push to main branch to trigger automatic release.')); - // Use npm version to bump and create git tag - try { - const newVersion = execSync(`npm version ${type} --no-git-tag-version`, { encoding: 'utf8' }).trim(); - console.log(chalk.green(`✅ Main package.json version bumped to ${newVersion}`)); - - // Also update installer package.json - const installerPackageJsonPath = path.join('tools', 'installer', 'package.json'); - if (fs.existsSync(installerPackageJsonPath)) { - const installerPackageJson = JSON.parse(fs.readFileSync(installerPackageJsonPath, 'utf8')); - installerPackageJson.version = newVersion.replace('v', ''); // Remove 'v' prefix if present - fs.writeFileSync(installerPackageJsonPath, JSON.stringify(installerPackageJson, null, 2) + '\n'); - console.log(chalk.green(`✅ Installer package.json version bumped to ${newVersion}`)); - } - - // Stage both package.json files - execSync('git add package.json'); - execSync(`git add ${installerPackageJsonPath}`); - - // Create commit and tag - execSync(`git commit -m "chore: bump version to ${newVersion}"`); - execSync(`git tag -a ${newVersion} -m "Release ${newVersion}"`); - - console.log(chalk.green(`✅ Created git tag: ${newVersion}`)); - console.log(chalk.yellow(`💡 Run 'git push && git push --tags' to publish`)); - - return newVersion; - } catch (error) { - console.error(chalk.red('❌ Version bump failed:'), error.message); - process.exit(1); - } + return null; } async function main() {