diff --git a/lib/build.js b/lib/build.js index fa0a00423645..2cc5720f181f 100644 --- a/lib/build.js +++ b/lib/build.js @@ -52,9 +52,27 @@ const touchOverriddenFiles = () => { }) } +/** + * Checks to make sure the src/chrome/VERSION matches brave-browser's package.json version + */ +const checkVersionsMatch = () => { + const srcChromeVersionDir = path.resolve(path.join(__dirname, '..', 'src', 'chrome', 'VERSION')) + const versionData = fs.readFileSync(srcChromeVersionDir, 'utf8') + const re = /MAJOR=(\d+)\s+MINOR=(\d+)\s+BUILD=(\d+)\s+PATCH=(\d+)/ + const found = versionData.match(re) + const braveVersionFromChromeFile = `${found[2]}.${found[3]}.${found[4]}` + if (braveVersionFromChromeFile !== config.braveVersion) { + console.warn(`Version files do not match!\nsrc/chrome/VERSION: ${braveVersionFromChromeFile}\nbrave-browser package.json version: ${config.braveVersion}`) + if (config.buildConfig === 'Release') { + process.exit(1) + } + } +} + const build = (buildConfig = config.defaultBuildConfig, options) => { config.buildConfig = buildConfig config.update(options) + checkVersionsMatch() touchOverriddenFiles() diff --git a/lib/config.js b/lib/config.js index 9a080051dccc..4a1f27c0512b 100644 --- a/lib/config.js +++ b/lib/config.js @@ -8,8 +8,11 @@ const packages = require('../package') const getNPMConfig = (path) => { const key = path.join('_').replace('-', '_') const npm_prefix = 'npm_config_' - const package_prefix = 'npm_package_config_' - return process.env[npm_prefix + key] || process.env[package_prefix + key] + const package_config_prefix = 'npm_package_config_' + const package_prefix = 'npm_package_' + return process.env[npm_prefix + key] || + process.env[package_config_prefix + key] || + process.env[package_prefix + key] } const Config = function () { @@ -36,10 +39,9 @@ const Config = function () { this.googleApiEndpoint = getNPMConfig(['brave_google_api_endpoint']) || 'https://www.googleapis.com/geolocation/v1/geolocate?key=' this.safeBrowsingApiEndpoint = getNPMConfig(['safe_browsing_api_endpoint']) || 'safebrowsing.brave.com' this.buildProjects() - const braveCoreDirPackage = path.join(this.projects['brave-core'].dir, 'package') - this.braveCoreVersion = (fs.existsSync(braveCoreDirPackage + '.json') && require(braveCoreDirPackage)['version']) || '0.0.0' + this.braveVersion = getNPMConfig(['version']) || '0.0.0.0' this.chromeVersion = getNPMConfig(['projects', 'chrome', 'tag']) || '0.0.0.0' - this.releaseTag = this.braveCoreVersion.split('+')[0] + this.releaseTag = this.braveVersion.split('+')[0] this.mac_signing_identifier = getNPMConfig(['mac_signing_identifier']) || '' this.mac_signing_keychain = getNPMConfig(['mac_signing_keychain']) || 'login' this.channel = '' @@ -47,7 +49,7 @@ const Config = function () { } Config.prototype.buildArgs = function () { - const version = this.braveCoreVersion + const version = this.braveVersion let version_parts = version.split('+')[0] version_parts = version_parts.split('.')