diff --git a/scripts/resolve-version-lib.js b/scripts/resolve-version-lib.js index ec1f7b1b83822..5885d96b6afd9 100755 --- a/scripts/resolve-version-lib.js +++ b/scripts/resolve-version-lib.js @@ -37,7 +37,8 @@ function resolveVersion(rootdir) { // validate that current version matches the requirements // - const currentVersion = require(versionFilePath).version; + const versions = require(versionFilePath); + const currentVersion = versions.version; if (!currentVersion.startsWith(`${majorVersion}.`)) { throw new Error(`current version "${currentVersion}" does not use the expected major version ${majorVersion}`); } @@ -68,6 +69,7 @@ function resolveVersion(rootdir) { return { version: currentVersion, + alphaVersion: versions.alphaVersion, versionFile, changelogFile, alphaChangelogFile, diff --git a/scripts/script-tests/resolve-version.test.js b/scripts/script-tests/resolve-version.test.js index 693e29234f023..1cabbb2acd795 100644 --- a/scripts/script-tests/resolve-version.test.js +++ b/scripts/script-tests/resolve-version.test.js @@ -17,6 +17,24 @@ happy({ marker: '0.0.0', prerelease: undefined, version: '2.1.0', + alphaVersion: undefined, + versionFile: 'version.v2.json' + } +}); + +happy({ + name: 'stable release with alpha modules', + inputs: { + 'release.json': { majorVersion: 2, releaseType: 'stable' }, + 'version.v2.json': { version: '2.1.0', alphaVersion: '2.1.0-alpha' }, + }, + expected: { + changelogFile: 'CHANGELOG.v2.md', + alphaChangelogFile: 'CHANGELOG.v2.alpha.md', + marker: '0.0.0', + prerelease: undefined, + version: '2.1.0', + alphaVersion: '2.1.0-alpha', versionFile: 'version.v2.json' } }); @@ -33,6 +51,7 @@ happy({ marker: '0.0.0', prerelease: 'alpha', version: '2.1.0-alpha.0', + alphaVersion: undefined, versionFile: 'version.v2.json' } }); @@ -49,6 +68,24 @@ happy({ marker: '0.0.0', prerelease: 'rc', version: '2.1.0-rc.0', + alphaVersion: undefined, + versionFile: 'version.v2.json' + } +}); + +happy({ + name: 'rc release with alpha modules', + inputs: { + 'release.json': { majorVersion: 2, releaseType: 'rc' }, + 'version.v2.json': { version: '2.0.0-rc.0', alphaVersion: '2.0.0-alpha.0' }, + }, + expected: { + changelogFile: 'CHANGELOG.v2.md', + alphaChangelogFile: 'CHANGELOG.v2.alpha.md', + marker: '0.0.0', + prerelease: 'rc', + version: '2.0.0-rc.0', + alphaVersion: '2.0.0-alpha.0', versionFile: 'version.v2.json' } }); @@ -65,6 +102,7 @@ happy({ marker: '0.0.0', prerelease: undefined, version: '1.72.0', + alphaVersion: undefined, versionFile: 'version.v1.json' } }); @@ -81,6 +119,7 @@ happy({ marker: '0.0.0', prerelease: undefined, version: '2.0.0-rc.0', + alphaVersion: undefined, versionFile: 'version.v2.json' } });