Skip to content
Snippets Groups Projects
Commit 79267523 authored by Andrew Clark's avatar Andrew Clark
Browse files

Update release script to support canary versions

parent d02fd7b4
No related merge requests found
...@@ -81,5 +81,7 @@ module.exports = { ...@@ -81,5 +81,7 @@ module.exports = {
spyOnDev: true, spyOnDev: true,
spyOnDevAndProd: true, spyOnDevAndProd: true,
spyOnProd: true, spyOnProd: true,
// TODO: Remove dependency on Promise.race
Promise: true,
}, },
}; };
...@@ -43,5 +43,8 @@ const check = async ({cwd}) => { ...@@ -43,5 +43,8 @@ const check = async ({cwd}) => {
}; };
module.exports = async params => { module.exports = async params => {
if (params.local) {
return;
}
return logPromise(check(params), 'Checking CircleCI status'); return logPromise(check(params), 'Checking CircleCI status');
}; };
...@@ -6,15 +6,21 @@ const chalk = require('chalk'); ...@@ -6,15 +6,21 @@ const chalk = require('chalk');
const {exec} = require('child-process-promise'); const {exec} = require('child-process-promise');
const {logPromise} = require('../utils'); const {logPromise} = require('../utils');
const update = async ({cwd}) => { const update = async ({cwd, branch, local}) => {
await exec('git fetch', {cwd}); if (!local) {
await exec('git checkout master', {cwd}); await exec('git fetch', {cwd});
await exec('git pull', {cwd}); }
await exec(`git checkout ${branch}`, {cwd});
if (!local) {
await exec('git pull', {cwd});
}
}; };
module.exports = async ({cwd}) => { module.exports = async params => {
return logPromise( return logPromise(
update({cwd}), update(params),
`Updating checkout ${chalk.yellow.bold(cwd)}` `Updating checkout ${chalk.yellow.bold(
params.cwd
)} on branch ${chalk.yellow.bold(params.branch)}}`
); );
}; };
...@@ -23,6 +23,25 @@ const paramDefinitions = [ ...@@ -23,6 +23,25 @@ const paramDefinitions = [
alias: 'v', alias: 'v',
description: 'Semantic version number', description: 'Semantic version number',
}, },
{
name: 'branch',
type: String,
alias: 'b',
description: 'Branch to build from; defaults to [bold]{master}',
defaultValue: 'master',
},
{
name: 'local',
type: Boolean,
description: "Don't pull changes from the remote branch. Also skips CI.",
},
{
name: 'tag',
type: String,
description:
'The npm dist tag; defaults to [bold]{latest} for a stable' +
'release, [bold]{next} for unstable',
},
]; ];
module.exports = { module.exports = {
......
...@@ -7,7 +7,10 @@ const {existsSync} = require('fs'); ...@@ -7,7 +7,10 @@ const {existsSync} = require('fs');
const {readJson} = require('fs-extra'); const {readJson} = require('fs-extra');
const {join} = require('path'); const {join} = require('path');
module.exports = async ({cwd, version}) => { module.exports = async ({cwd, version, local}) => {
if (local) {
return;
}
const packagePath = join( const packagePath = join(
cwd, cwd,
'build', 'build',
......
...@@ -8,10 +8,21 @@ const {join} = require('path'); ...@@ -8,10 +8,21 @@ const {join} = require('path');
const semver = require('semver'); const semver = require('semver');
const {execRead, execUnlessDry, logPromise} = require('../utils'); const {execRead, execUnlessDry, logPromise} = require('../utils');
const push = async ({cwd, dry, packages, version}) => { const push = async ({cwd, dry, packages, version, tag}) => {
const errors = []; const errors = [];
const isPrerelease = semver.prerelease(version); let isPrerelease;
const tag = isPrerelease ? 'next' : 'latest'; if (tag === undefined) {
// No tag was provided. Check the version.
isPrerelease = semver.prerelease(version);
if (isPrerelease) {
tag = 'next';
} else {
tag = 'latest';
}
} else {
// Any tag besides `latest` is a prerelease
isPrerelease = tag === 'latest';
}
const publishProject = async project => { const publishProject = async project => {
try { try {
...@@ -76,5 +87,6 @@ const push = async ({cwd, dry, packages, version}) => { ...@@ -76,5 +87,6 @@ const push = async ({cwd, dry, packages, version}) => {
}; };
module.exports = async params => { module.exports = async params => {
console.log(params);
return logPromise(push(params), 'Publishing packages to NPM'); return logPromise(push(params), 'Publishing packages to NPM');
}; };
...@@ -10,5 +10,8 @@ const push = async ({cwd, dry}) => { ...@@ -10,5 +10,8 @@ const push = async ({cwd, dry}) => {
}; };
module.exports = async params => { module.exports = async params => {
if (params.local) {
return;
}
return logPromise(push(params), 'Pushing to git remote'); return logPromise(push(params), 'Pushing to git remote');
}; };
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment