Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use brave-browser version and check for inconsistency with src/chrome/VERSION #658

Merged
merged 1 commit into from
Jul 30, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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