@@ -10,6 +10,7 @@ import * as os from 'os';
1010import { exec } from 'child_process' ;
1111import { promisify } from 'util' ;
1212import { findTagsByVersion } from './gitTasks' ;
13+ import minimist from 'minimist' ;
1314
1415const execAsync = promisify ( exec ) ;
1516
@@ -20,18 +21,51 @@ function logWarning(message: string, error?: unknown): void {
2021 }
2122}
2223
24+ /**
25+ * Calculate the next release (stable) version from the current version.
26+ * Rounds up the minor version to the next tens version.
27+ * @param currentVersion The current version in "major.minor" format (e.g., "2.74")
28+ * @returns The next stable release version (e.g., "2.80")
29+ */
30+ export function getNextReleaseVersion ( currentVersion : string ) : string {
31+ const split = currentVersion . split ( '.' ) ;
32+ const major = parseInt ( split [ 0 ] ) ;
33+ const minor = parseInt ( split [ 1 ] ) ;
34+
35+ // Round up to the next tens version
36+ const nextTensMinor = Math . ceil ( ( minor + 1 ) / 10 ) * 10 ;
37+
38+ return `${ major } .${ nextTensMinor } ` ;
39+ }
40+
2341gulp . task ( 'incrementVersion' , async ( ) : Promise < void > => {
42+ const argv = minimist ( process . argv . slice ( 2 ) ) ;
43+ const isReleaseCandidate = argv [ 'releaseCandidate' ] === true || argv [ 'releaseCandidate' ] === 'true' ;
44+
2445 // Get the current version from version.json
2546 const versionFilePath = path . join ( path . resolve ( __dirname , '..' ) , 'version.json' ) ;
2647 const file = fs . readFileSync ( versionFilePath , 'utf8' ) ;
2748 const versionJson = JSON . parse ( file ) ;
2849
29- // Increment the minor version
50+ // Calculate new version
3051 const version = versionJson . version as string ;
3152 const split = version . split ( '.' ) ;
32- const newVersion = `${ split [ 0 ] } .${ parseInt ( split [ 1 ] ) + 1 } ` ;
33-
34- console . log ( `Updating ${ version } to ${ newVersion } ` ) ;
53+ let newVersion : string ;
54+
55+ if ( isReleaseCandidate ) {
56+ // If this is a release candidate, increment to be higher than the next stable version
57+ // e.g., if current is 2.74, next stable is 2.80, so main should be 2.81
58+ const nextStableVersion = getNextReleaseVersion ( version ) ;
59+ const stableSplit = nextStableVersion . split ( '.' ) ;
60+ newVersion = `${ stableSplit [ 0 ] } .${ parseInt ( stableSplit [ 1 ] ) + 1 } ` ;
61+ console . log (
62+ `Release candidate mode: Updating ${ version } to ${ newVersion } (next stable would be ${ nextStableVersion } )`
63+ ) ;
64+ } else {
65+ // Normal increment: just increment the minor version
66+ newVersion = `${ split [ 0 ] } .${ parseInt ( split [ 1 ] ) + 1 } ` ;
67+ console . log ( `Updating ${ version } to ${ newVersion } ` ) ;
68+ }
3569
3670 // Write the new version back to version.json
3771 versionJson . version = newVersion ;
@@ -186,3 +220,27 @@ async function generatePRList(startSHA: string, endSHA: string): Promise<string[
186220 throw error ;
187221 }
188222}
223+
224+ /**
225+ * Update version.json to the next stable release version.
226+ * This task is used when snapping from prerelease to release.
227+ * It updates the version to round up to the next tens version (e.g., 2.74 -> 2.80).
228+ */
229+ gulp . task ( 'updateVersionForRelease' , async ( ) : Promise < void > => {
230+ // Get the current version from version.json
231+ const versionFilePath = path . join ( path . resolve ( __dirname , '..' ) , 'version.json' ) ;
232+ const file = fs . readFileSync ( versionFilePath , 'utf8' ) ;
233+ const versionJson = JSON . parse ( file ) ;
234+
235+ const currentVersion = versionJson . version as string ;
236+ const releaseVersion = getNextReleaseVersion ( currentVersion ) ;
237+
238+ console . log ( `Updating version from ${ currentVersion } to stable release version ${ releaseVersion } ` ) ;
239+
240+ // Write the new version back to version.json
241+ versionJson . version = releaseVersion ;
242+ const newJson = JSON . stringify ( versionJson , null , 4 ) ;
243+ console . log ( `New json: ${ newJson } ` ) ;
244+
245+ fs . writeFileSync ( versionFilePath , newJson ) ;
246+ } ) ;
0 commit comments