Skip to content

Commit

Permalink
Merge pull request #658 from brave/version-master
Browse files Browse the repository at this point in the history
Use brave-browser version and check for inconsistency with src/chrome/VERSION
  • Loading branch information
bbondy committed Jul 30, 2018
2 parents d5bc16f + c63e124 commit f07aacb
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 6 deletions.
18 changes: 18 additions & 0 deletions lib/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down
14 changes: 8 additions & 6 deletions lib/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 () {
Expand All @@ -36,18 +39,17 @@ 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 = ''
this.sccache = getNPMConfig(['sccache'])
}

Config.prototype.buildArgs = function () {
const version = this.braveCoreVersion
const version = this.braveVersion
let version_parts = version.split('+')[0]
version_parts = version_parts.split('.')

Expand Down

0 comments on commit f07aacb

Please sign in to comment.