Skip to content

Commit

Permalink
v1.0.0 Candidate with build changes for better docker tags
Browse files Browse the repository at this point in the history
  • Loading branch information
joelgriffith committed Jan 19, 2019
1 parent eaf5ece commit 4e172a9
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 39 deletions.
15 changes: 15 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# 1.0.0

🥁 -- Stable version 1.0 is here! While this doesn't include major functionality changes, it _does_ change how the docker builds are generated going forward. The versioning will now contain two pieces of crucial information: the version of the _browserless_ service + the version of Chrome under-the-hood. For instance `1.2.3-puppeteer-1.10.0` is browserless at `1.2.3`, exposing puppeteer at `1.10.0`.

Similar to how NodeJS itself does docker releases, we'll now provide releases in 3 distinct ways:

- An _immutable_, pinned version release: `1.0.0-puppeteer-1.11.0`
- A mutable minor version release: `1.1-puppeteer-1.12.0`
- A mutable major version release: `1-puppeteer-1.9.0`

For production deployments, we recommend using _pinned_ version releases as they won't change once released. The mutable minor/major releases will receive on-going updates whenever we do changes that are bug-fixes or feature release. Even with the best intentions it's possible that instability can be introduced with these mutable images, hence why recommend the pinned version releases.

Finally, we'll continue to ship support for the last 5 minor versions of Puppeteer + the Google Chrome (stable). Old images will remain, but newer versions of browserless won't be included.

We'll continue to keep this changelog up-to-date anytime we do docker releases.
2 changes: 1 addition & 1 deletion hooks/build
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ function readJson {

USE_CHROME_STABLE=false;

if [ "$SOURCE_BRANCH" = "chrome-stable" ]; then
if [[ $SOURCE_BRANCH == *"chrome-stable"* ]]; then
USE_CHROME_STABLE=true;
fi

Expand Down
10 changes: 2 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "browserless-chrome",
"version": "1.0.0-alpha",
"version": "1.0.0",
"description": "Chrome-as-a-service on your own hardware or in the cloud.",
"repository": "joelgriffith/browserless",
"main": "build/index.js",
Expand All @@ -22,20 +22,14 @@
"symlink-chrome": "node ./scripts/symlink-chrome"
},
"puppeteerVersions": {
"puppeteer-1.4.0": "1.4.0",
"puppeteer-1.5.0": "1.5.0",
"puppeteer-1.6.2": "1.6.2",
"puppeteer-1.7.0": "1.7.0",
"puppeteer-1.8.0": "1.8.0",
"puppeteer-1.9.0": "1.9.0",
"puppeteer-1.10.0": "1.10.0",
"puppeteer-1.11.0": "1.11.0",
"chrome-stable": "1.4.0"
},
"releaseBranches": [
"puppeteer-1.4.0",
"puppeteer-1.5.0",
"puppeteer-1.6.2",
"chromeVersions": [
"puppeteer-1.7.0",
"puppeteer-1.8.0",
"puppeteer-1.9.0",
Expand Down
59 changes: 29 additions & 30 deletions scripts/deploy.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,15 @@ const child = require('child_process');
const util = require('util');
const debug = require('debug')('browserless-docker-deploy');
const exec = util.promisify(child.exec);
const {
flatMap,
noop
} = require('lodash');

const {
releaseBranches,
chromeVersions,
puppeteerVersions,
version,
} = require('../package.json');

const DEPLOY_BRANCH = 'master';
Expand All @@ -32,15 +37,15 @@ async function checkoutReleaseBranch () {
return logExec(`git checkout ${DEPLOY_BRANCH} --quiet`);
}

const deployPuppeteerVersion = async (branch) => {
const version = puppeteerVersions[branch];
const deployVersion = async (branch, chromeVersion) => {
const version = puppeteerVersions[chromeVersion];

debug(`${branch}: Deploying release of browserless, puppeteer@${version}`);

const currentBranch = await logExec('git rev-parse --abbrev-ref HEAD');

if (currentBranch !== DEPLOY_BRANCH) {
await checkoutReleaseBranch;
await checkoutReleaseBranch();
}

await logExec(`git checkout -b ${branch} --quiet`);
Expand All @@ -59,34 +64,17 @@ const deployPuppeteerVersion = async (branch) => {
}

// Have to do `&> /dev/null` to avoid remote messages
await logExec(`git push origin ${branch} --quiet --no-verify &> /dev/null`);
}

async function cleanLocalBranches() {
return Promise.all(
releaseBranches.map((branch) =>
exec(`git branch -D ${branch}`)
.catch(() => {})
)
);
await logExec(`git push origin ${branch} --force --quiet --no-verify &> /dev/null`);
}

async function cleanRemoteBranches() {
async function deleteBranches(branches) {
return Promise.all(
releaseBranches.map((branch) =>
exec(`git push origin --delete ${branch} --quiet --no-verify`)
.catch(() => {})
branches.map((branch) =>
exec(`git branch -D ${branch}`).catch(noop)
)
);
}

async function cleanReleaseBranches() {
return Promise.all([
cleanLocalBranches(),
cleanRemoteBranches(),
]);
}

async function deploy () {
const branch = await logExec('git rev-parse --abbrev-ref HEAD');

Expand All @@ -103,14 +91,25 @@ async function deploy () {
}

debug(`On branch ${DEPLOY_BRANCH} and no un-tracked files in git, proceeding to build deployment.`);
debug(`Cleaning out local and remote deployment branches`);

await cleanReleaseBranches();
const branches = flatMap(chromeVersions, (chromeVersion) => {
const [ major, minor, patch ] = version.split('.');

const patchBranch = `${major}.${minor}.${patch}-${chromeVersion}`;
const minorBranch = `${major}.${minor}-${chromeVersion}`;
const majorBranch = `${major}-${chromeVersion}`;

return [
[ patchBranch, chromeVersion ],
[ minorBranch, chromeVersion ],
[ majorBranch, chromeVersion ],
];
});

debug(`Starting release`);
await deleteBranches(branches.map(([ branch ]) => branch));

await releaseBranches.reduce((lastJob, puppeteerVersion) =>
lastJob.then(() => deployPuppeteerVersion(puppeteerVersion)), Promise.resolve());
await branches.reduce((lastJob, [branch, chromeVersion]) =>
lastJob.then(() => deployVersion(branch, chromeVersion)), Promise.resolve());

debug(`Checking out master and removing release branches.`);

Expand Down

0 comments on commit 4e172a9

Please sign in to comment.