Skip to content

Commit 3c9b183

Browse files
Address review: integrate with main repo release/start.sh for version determination
- Remove custom calculateNextVersion function - Add determineVersionFromMainRepo() to use main Jaeger repo logic - Add fallback version determination when main repo unavailable - Update demo script to reflect new approach - Maintains consistency with main Jaeger repository versioning
1 parent f3c393a commit 3c9b183

File tree

2 files changed

+77
-63
lines changed

2 files changed

+77
-63
lines changed

scripts/release/demo.js

Lines changed: 19 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -63,21 +63,17 @@ function getCurrentVersion() {
6363
}
6464
}
6565

66-
// Calculate next version based on current version
67-
function calculateNextVersion(currentVersion, versionType = 'patch') {
66+
// Simulate version determination using main repository logic
67+
function simulateVersionDetermination(currentVersion) {
68+
logInfo('Simulating version determination using main Jaeger repository logic...');
69+
70+
// In the real implementation, this would call the main repo's start.sh script
71+
// For demo purposes, we'll simulate a patch version increment
6872
const [major, minor, patch] = currentVersion.split('.').map(Number);
73+
const patchVersion = `${major}.${minor}.${patch + 1}`;
6974

70-
switch (versionType) {
71-
case 'major':
72-
return `${major + 1}.0.0`;
73-
case 'minor':
74-
return `${major}.${minor + 1}.0`;
75-
case 'patch':
76-
return `${major}.${minor}.${patch + 1}`;
77-
default:
78-
logError(`Invalid version type: ${versionType}. Use: major, minor, or patch`);
79-
process.exit(1);
80-
}
75+
logInfo(`Main repo logic would determine: ${patchVersion}`);
76+
return patchVersion;
8177
}
8278

8379
// Simulate the complete workflow
@@ -89,20 +85,16 @@ function simulateWorkflow() {
8985
const currentVersion = getCurrentVersion();
9086
logInfo(`Current version: ${currentVersion}`);
9187

92-
// Step 2: Calculate next versions
93-
const patchVersion = calculateNextVersion(currentVersion, 'patch');
94-
const minorVersion = calculateNextVersion(currentVersion, 'minor');
95-
const majorVersion = calculateNextVersion(currentVersion, 'major');
88+
// Step 2: Simulate version determination using main repo logic
89+
const selectedVersion = simulateVersionDetermination(currentVersion);
9690

97-
console.log('\n📋 Available version options:');
98-
console.log(`1) Patch (bug fixes) → ${patchVersion}`);
99-
console.log(`2) Minor (new features) → ${minorVersion}`);
100-
console.log(`3) Major (breaking) → ${majorVersion}`);
101-
console.log(`4) Custom version → Enter manually`);
91+
console.log('\n📋 Version determination process:');
92+
console.log(' 🔍 Checking main Jaeger repository...');
93+
console.log(' 📋 Using release/start.sh script logic...');
94+
console.log(` ✅ Determined version: ${selectedVersion}`);
10295

103-
// Step 3: Simulate version selection (demo uses patch)
104-
const selectedVersion = patchVersion;
105-
console.log(`\n✅ Selected: Patch version → ${selectedVersion}`);
96+
// Step 3: Show version selection result
97+
console.log(`\n✅ Using version determined by main repository: ${selectedVersion}`);
10698

10799
// Step 4: Show what would be updated
108100
console.log('\n🔧 Files that would be updated:');
@@ -177,8 +169,9 @@ function simulateWorkflow() {
177169
console.log('\n🔗 Integration with existing tools:');
178170
console.log(' 📦 make changelog → Downloads from main Jaeger repo');
179171
console.log(' 📦 make draft-release → Downloads from main Jaeger repo');
180-
console.log(' 📦 make prepare-release → NEW: Our automation');
172+
console.log(' 📦 make prepare-release → NEW: Uses main repo version logic');
181173
console.log(' 📦 GitHub Actions → Existing release workflow');
174+
console.log(' 📦 release/start.sh → Main repo version determination');
182175

183176
console.log('\n✨ Demo completed! This shows the complete automation workflow.');
184177
console.log(' To run the actual automation: make prepare-release');

scripts/release/prepare-release.js

Lines changed: 58 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -64,53 +64,74 @@ function getCurrentVersion() {
6464
}
6565
}
6666

67-
// Calculate next version based on current version
68-
function calculateNextVersion(currentVersion, versionType = 'patch') {
69-
const [major, minor, patch] = currentVersion.split('.').map(Number);
67+
// Call the main Jaeger repository's release/start.sh script to determine version
68+
function determineVersionFromMainRepo() {
69+
logInfo('Determining version using main Jaeger repository logic...');
7070

71-
switch (versionType) {
72-
case 'major':
73-
return `${major + 1}.0.0`;
74-
case 'minor':
75-
return `${major}.${minor + 1}.0`;
76-
case 'patch':
77-
return `${major}.${minor}.${patch + 1}`;
78-
default:
79-
logError(`Invalid version type: ${versionType}. Use: major, minor, or patch`);
80-
process.exit(1);
71+
try {
72+
// Check if we can access the main Jaeger repository
73+
const mainRepoPath = path.join(__dirname, '../../../jaeger');
74+
const startScriptPath = path.join(mainRepoPath, 'scripts/release/start.sh');
75+
76+
if (!fs.existsSync(startScriptPath)) {
77+
logWarning('Main Jaeger repository not found. Using fallback version determination.');
78+
return determineVersionFallback();
79+
}
80+
81+
// Change to main repo directory and run the start script
82+
const originalCwd = process.cwd();
83+
process.chdir(mainRepoPath);
84+
85+
try {
86+
// Run the start script in dry-run mode to get version without making changes
87+
const result = execSync('bash scripts/release/start.sh --dry-run', {
88+
encoding: 'utf8',
89+
stdio: 'pipe'
90+
});
91+
92+
// Extract version from the output (this may need adjustment based on actual output format)
93+
const versionMatch = result.match(/version[:\s]+([0-9]+\.[0-9]+\.[0-9]+)/i);
94+
if (versionMatch) {
95+
return versionMatch[1];
96+
}
97+
98+
logWarning('Could not extract version from main repo script. Using fallback.');
99+
return determineVersionFallback();
100+
} finally {
101+
process.chdir(originalCwd);
102+
}
103+
} catch (error) {
104+
logWarning(`Failed to use main repo script: ${error.message}. Using fallback.`);
105+
return determineVersionFallback();
81106
}
82107
}
83108

84-
// Interactive version selection
109+
// Fallback version determination when main repo is not available
110+
function determineVersionFallback() {
111+
const currentVersion = getCurrentVersion();
112+
logInfo(`Current version: ${currentVersion}`);
113+
114+
// Simple patch version increment as fallback
115+
const [major, minor, patch] = currentVersion.split('.').map(Number);
116+
return `${major}.${minor}.${patch + 1}`;
117+
}
118+
119+
// Version selection using main repository logic
85120
function selectVersion(currentVersion) {
86121
logInfo(`Current version: ${currentVersion}`);
87122
console.log('');
88-
console.log('Select the type of version bump:');
89-
console.log(`1) Patch (bug fixes, minor improvements) - ${calculateNextVersion(currentVersion, 'patch')}`);
90-
console.log(`2) Minor (new features, backward compatible) - ${calculateNextVersion(currentVersion, 'minor')}`);
91-
console.log(`3) Major (breaking changes) - ${calculateNextVersion(currentVersion, 'major')}`);
92-
console.log('4) Custom version');
123+
124+
// Try to use main repository logic first
125+
const newVersion = determineVersionFromMainRepo();
126+
127+
logInfo(`Determined next version: ${newVersion}`);
93128
console.log('');
94129

95-
// For demo purposes, we'll use patch version
96-
// In a real implementation, you'd use readline or similar for user input
97-
const choice = '1'; // Default to patch
98-
console.log('Selected: Patch version (demo mode)');
130+
// For now, we'll use the determined version directly
131+
// In a real implementation, you might want to allow user confirmation
132+
console.log('Using version determined by main Jaeger repository logic');
99133

100-
switch (choice) {
101-
case '1':
102-
return calculateNextVersion(currentVersion, 'patch');
103-
case '2':
104-
return calculateNextVersion(currentVersion, 'minor');
105-
case '3':
106-
return calculateNextVersion(currentVersion, 'major');
107-
case '4':
108-
// In real implementation, prompt for custom version
109-
return '1.74.0'; // Demo custom version
110-
default:
111-
logError('Invalid choice. Please select 1-4.');
112-
process.exit(1);
113-
}
134+
return newVersion;
114135
}
115136

116137
// Confirm version selection

0 commit comments

Comments
 (0)