feat: improve semantic-release automation and disable manual version bumping
- Add custom semantic-release plugin to sync installer package.json - Update semantic-release config to include installer package.json in releases - Disable manual version bump script in favor of conventional commits - Add helper script for version synchronization - This ensures semantic-release fully manages both package.json files BREAKING CHANGE: Manual version bumping via npm scripts is now disabled. Use conventional commits for automated releases. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -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}"
|
||||
}
|
||||
],
|
||||
|
||||
31
tools/semantic-release-sync-installer.js
Normal file
31
tools/semantic-release-sync-installer.js
Normal file
@@ -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 };
|
||||
34
tools/sync-installer-version.js
Normal file
34
tools/sync-installer-version.js
Normal file
@@ -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 };
|
||||
@@ -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() {
|
||||
|
||||
Reference in New Issue
Block a user