Skip to content
This repository has been archived by the owner on Dec 11, 2019. It is now read-only.

Multiple channels release with different installed locations and user dir #10552

Merged
merged 1 commit into from
Nov 3, 2017
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
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ app/extensions/gen
app/extensions/brave/gen
app/extensions/torrent/gen
*.pfx
buildConfig.js
js/constants/buildConfig.js

# HTTPS Everywhere files
rulesets.json
Expand Down
12 changes: 12 additions & 0 deletions app/buildConfig.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/. */

'use strict'

// The package npm task builds this module
const config = require('../js/constants/buildConfig')

exports.browserLaptopRev = () => process.env.NODE_ENV === 'development'
? require('git-rev-sync').long()
: config.BROWSER_LAPTOP_REV
29 changes: 24 additions & 5 deletions app/channel.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,31 @@ exports.formattedChannel = () => {
const locale = require('./locale')

const channelMapping = {
'dev': locale.translation('channelDev'),
'beta': locale.translation('channelBeta')
'dev': locale.translation('channelRelease'),
'beta': locale.translation('channelBeta'),
'developer': locale.translation('channelDeveloper'),
'nightly': locale.translation('channelNightly')
}
return Object.keys(channelMapping).includes(channel) ? channelMapping[channel] : channel
}

exports.browserLaptopRev = () => process.env.NODE_ENV === 'development'
? require('git-rev-sync').long()
: config.BROWSER_LAPTOP_REV
exports.getLinuxDesktopName = () => {
let desktopName
switch (channel) {
case 'dev':
desktopName = 'brave.desktop'
break
case 'beta':
desktopName = 'brave-beta.desktop'
break
case 'developer':
desktopName = 'brave-developer.desktop'
break
case 'nightly':
desktopName = 'brave-nightly.desktop'
break
default:
desktopName = 'brave.desktop'
}
return desktopName
}
4 changes: 3 additions & 1 deletion app/extensions/brave/locales/en-US/app.properties
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,9 @@ certErrorSafety=Back to safety
certErrorShowCertificate=Show Certificate
certErrorText=This site cannot be loaded due to a certificate error:
channelBeta=Beta
channelDev=Release
channelRelease=Release
channelDeveloper=Developer
channelNightly=Nightly
checkDefaultOnStartup=Always check on startup
city=City
clear=Clear
Expand Down
3 changes: 2 additions & 1 deletion app/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,8 @@ app.on('ready', () => {
if (['development', 'test'].includes(process.env.NODE_ENV)) {
isDefaultBrowser = true
} else if (process.platform === 'linux') {
const desktopName = 'brave.desktop'
const Channel = require('./channel')
const desktopName = Channel.getLinuxDesktopName()
isDefaultBrowser = app.isDefaultProtocolClient('', desktopName)
} else {
isDefaultBrowser = defaultProtocols.every(p => app.isDefaultProtocolClient(p))
Expand Down
4 changes: 3 additions & 1 deletion app/locale.js
Original file line number Diff line number Diff line change
Expand Up @@ -267,8 +267,10 @@ var rendererIdentifiers = function () {
'allowAutoplay',
'autoplayMedia',
// Release channels
'channelDev',
'channelRelease',
'channelBeta',
'channelDeveloper',
'channelNightly',
'spellCheckLanguages'
].concat(countryCodes).concat(availableLanguages)
}
Expand Down
3 changes: 2 additions & 1 deletion app/sessionStore.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ const filtering = require('./filtering')
const autofill = require('./autofill')
const {navigatableTypes} = require('../js/lib/appUrlUtil')
const Channel = require('./channel')
const BuildConfig = require('./buildConfig')
const {isImmutable, makeImmutable, deleteImmutablePaths} = require('./common/state/immutableUtil')
const {getSetting} = require('../js/settings')
const platformUtil = require('./common/lib/platformUtil')
Expand Down Expand Up @@ -470,7 +471,7 @@ const safeGetVersion = (fieldName, getFieldVersion) => {
const setVersionInformation = (immutableData) => {
const versionFields = [
['Brave', app.getVersion],
['rev', Channel.browserLaptopRev],
['rev', BuildConfig.browserLaptopRev],
['Muon', () => { return process.versions['atom-shell'] }],
['libchromiumcontent', () => { return process.versions['chrome'] }],
['V8', () => { return process.versions.v8 }],
Expand Down
33 changes: 31 additions & 2 deletions app/windowsInit.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,25 @@ const spawn = childProcess.spawn
const spawnSync = childProcess.spawnSync
const execSync = childProcess.execSync
const app = electron.app
const appUserModelId = 'com.squirrel.brave.Brave'
const Channel = require('./channel')
let appUserModelId = 'com.squirrel.brave.Brave'
switch (Channel.channel()) {
case 'nightly':
Copy link
Member

@bsclifton bsclifton Aug 29, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

kind of a lame nit-pick; you could store the text representation of the channels in an enum-like format in channel.js:

const channelStrings = {
  RELEASE: 'dev',
  BETA: 'beta',
  // ..
}

and then export / import from this file. Will make updating the constants easier 😄

switch (Channel.channel()) {
  case Channel.name.NIGHTLY:
}

appUserModelId = 'com.squirrel.BraveNightly.BraveNightly'
break
case 'developer':
appUserModelId = 'com.squirrel.BraveDeveloper.BraveDeveloper'
break
case 'beta':
appUserModelId = 'com.squirrel.BraveBeta.BraveBeta'
break
case 'dev':
appUserModelId = 'com.squirrel.brave.Brave'
break
default:
appUserModelId = 'com.squirrel.brave.Brave'
break
}

const getBraveBinPath = () => {
const appPath = app.getPath('exe')
Expand Down Expand Up @@ -39,6 +57,7 @@ function CopyManifestFile () {
if (process.platform === 'win32') {
const shouldQuit = require('electron-squirrel-startup')
const cmd = process.argv[1]
const channel = Channel.channel()
if (cmd === '--squirrel-install' || cmd === '--squirrel-updated') {
// The manifest file is used to customize the look of the Start menu tile.
// This function copies it from the versioned folder to the parent folder
Expand All @@ -52,9 +71,19 @@ if (process.platform === 'win32') {
spawnSync(getBraveDefaultsBinPath(), ['-uninstall'])
}

if (shouldQuit()) {
if (shouldQuit(channel)) {
process.exit(0)
}

const userDataDirSwitch = '--user-data-dir=brave-' + channel
if (channel !== 'dev' && !process.argv.includes(userDataDirSwitch)) {
if (cmd === '--squirrel-firstrun') {
app.relaunch({args: [userDataDirSwitch, '--relaunch']})
} else {
app.relaunch({args: process.argv.slice(1) + [userDataDirSwitch, '--relaunch']})
}
app.quit()
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a slick implementation! 😄 Thanks for the recommendation, @bbondy 😄 👍

}

app.on('will-finish-launching', () => {
Expand Down
83 changes: 83 additions & 0 deletions docs/buildingReleases.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
# Overview of our build process for releases

[brave/browser-laptop](https://github.com/brave/browser-laptop) maintains its own version of [electron](https://github.com/brave/electron) and therefore also its own version of [electron-prebuilt](https://github.com/brave/electron-prebuilt).
Releases of `brave/electron` get added to the `gh-pages` branch of [brave/browser-electron-releases](https://github.com/brave/browser-laptop-releases/tree/gh-pages).
`brave/browser-laptop`'s dependency on `brave/electron-prebuilt` will download directly from `brave/browser-laptop-releases` github public page.

# Creating a new Brave Electron release

To create a new release of `brave/electron` for use in `brave/electron-prebuilt`:

- Clone electron with `git clone --recursive git@github.com:brave/electron`
- Rebase `brave/electron`'s commits to the upstream tag you'd like to create a release for. e.g. `git rebase v0.37.2`
- Make sure the submodule dependencies in `vendor/` are up to date.
- For Linux and macOS builds, run `ELECTRON_RELEASE=1 ATOM_SHELL_GITHUB_TOKEN=<your-github-token> LIBCHROMIUMCONTENT_MIRROR=https://s3.amazonaws.com/brave-laptop-binaries/libchromiumcontent ./script/cibuild`. Replace `<your-github-token>` with a token generated from https://github.com/settings/tokens
- For Windows builds, run `ELECTRON_RELEASE=1 ATOM_SHELL_GITHUB_TOKEN=<your-github-token> LIBCHROMIUMCONTENT_MIRROR=https://s3.amazonaws.com/brave-laptop-binaries/libchromiumcontent npm run cibuild-windows`.
- Manually download the release zip to a subfolder of `brave/browser-laptop-releases` and push it out.
- Mark the release draft as completed in the `brave/electron` repository releases page.
- Increase the version number of the package.json file so that `npm install` in `browser-laptop` will start using it.

# Create a new Brave browser release

First follow the steps in the previous section.

```
git clone git@github.com/brave/browser-laptop
rm -Rf ~/.electron
npm install
```

If you already have the repo checked out, it's recommended to `rm -Rf node_modules` instead of the clone.

Then do the following per OS:

**macOS:**

```
CHANNEL=dev npm run build-package
CHANNEL=dev IDENTIFIER=id-here npm run build-installer
```

**Windows:**

```
CHANNEL=dev npm run build-package
CHANNEL=dev CERT_PASSWORD=‘password-here’ npm run build-installer
````

Check virus scan: https://www.virustotal.com/en/

**Linux:**
```
./node_modules/.bin/webpack
CHANNEL=dev npm run build-package
CHANNEL=dev npm run build-installer
tar -jcvf Brave.tar.bz2 ./Brave-linux-x64
```

# Dependencies

[Brave's electron](https://github.com/brave/electron) fork maintains its own versions of [brightray](https://github.com/brave/brightray), [libchromiumcontent](https://github.com/brave/libchromiumcontent), and [node](https://github.com/brave/node).
The primary purpose of doing this is to be able to update dependencies for security releases faster than Electron does.


# Updating Chromium / Brightray

- Generate a new tarball from `brave/chromium-source-tarball` for the new version `./script/bootstrap` followed by `./script/sync 49.0.2623.75` followed by `GITHUB_TOKEN=key-here ./script/upload`.
- Rebase `brave/libchromiumcontent` from `atom/libchromiumcontent` upstream.
- Change `brave/libchromiumcontent/VERSION` to contain the chromium version tag to change to. Example `49.0.2623.75`. You can see the latest tags here: https://chromium.googlesource.com/chromium/src.git/+refs
- You can create patches as needed inside `brave/libchromiumcontent/patches`. They will be automatically applied when doing builds.
- Some of the patches just mentioned will need rebasing on the new version.
- run `LIBCHROMIUMCONTENT_S3_BUCKET=brave-laptop-binaries LIBCHROMIUMCONTENT_S3_ACCESS_KEY=key-here AWS_ACCESS_KEY_SECRET=key-here AWS_ACCESS_KEY_SECRET=key-here LIBCHROMIUMCONTENT_S3_SECRET_KEY=key-here ./script/cibuild`.
- Brave's S3 bucket `brave-laptop-binaries` will be updated with the needed binaries.
- Update `brave/brightray`'s `/vendor/libchromiumcontent` submodule to point to the latest `brave/libchromiumcontent` changeset.
- From `brave/electron/script/lib/config.py` change `LIBCHROMIUMCONTENT_COMMIT` to point to the correct changeset from `brave/libchromiumcontent`.
- Update `brave/electron`'s `/vendor/brighray` submodule to point to the latest `brave/brightray` changeset.
- Update `brave/electron/atom/common/chrome_version.h` to include the latest version. I think it is also set automatically on builds though.

# Updating Node

- Rebase `brave/node` from a tag or changeset in `https://github.com/nodejs/node`.
- Update `brave/electron/vendor/node` submodule to refer to the latest changeset in `brave/node`.
- Update each of the building machines to match the version of Node that you're upgrading to. This is needed because `postinstall` rebuilds native modules and it should match the exact Node version.
- You can tell which Node version we're on by looking at the first `brave/node` commit which is not from `electron/node`. I.e. the first one from `nodejs/node`.
3 changes: 2 additions & 1 deletion js/constants/appConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ const isTest = process.env.NODE_ENV === 'test'
const buildConfig = require('./buildConfig')
const isProduction = buildConfig.nodeEnv === 'production'
const {fullscreenOption, autoplayOption} = require('../../app/common/constants/settingsEnums')
const Channel = require('../../app/channel')

module.exports = {
name: 'Brave',
Expand Down Expand Up @@ -135,7 +136,7 @@ module.exports = {
'general.show-home-button': false,
'general.autohide-menu': true,
'general.wide-url-bar': false,
'general.check-default-on-startup': true,
'general.check-default-on-startup': Channel.channel() === 'dev',
'general.download-default-path': '',
'general.download-always-ask': true,
'general.spellcheck-enabled': true,
Expand Down
3 changes: 2 additions & 1 deletion js/stores/appStore.js
Original file line number Diff line number Diff line change
Expand Up @@ -493,7 +493,8 @@ const handleAppAction = (action) => {
if (action.useBrave) {
let isDefaultBrowser
if (platformUtil.isLinux()) {
const desktopName = 'brave.desktop'
const Channel = require('../../app/channel')
const desktopName = Channel.getLinuxDesktopName()
for (const p of defaultProtocols) {
app.setAsDefaultProtocolClient(p, desktopName)
app.setAsDefaultProtocolClient('', desktopName)
Expand Down
File renamed without changes.
Loading