@@ -64,53 +64,74 @@ function getCurrentVersion() {
64
64
}
65
65
}
66
66
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...' ) ;
70
70
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 ( / v e r s i o n [: \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 ( ) ;
81
106
}
82
107
}
83
108
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
85
120
function selectVersion ( currentVersion ) {
86
121
logInfo ( `Current version: ${ currentVersion } ` ) ;
87
122
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 } ` ) ;
93
128
console . log ( '' ) ;
94
129
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' ) ;
99
133
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 ;
114
135
}
115
136
116
137
// Confirm version selection
0 commit comments