@samitouri / QOS-React-2 / commits / 1fd205ad2d

Additional release script options for publishing canary versions (#12219)

* Additional release script options for publishing canary versions - `branch` specifies a branch other than master - `local` skips pulling from the remote branch and checking CircleCI - `tag` specifies an npm dist tag other than `latest` or `next` We may add a higher-level `canary` option in the future. * Address Brian's feedback: - Updated description of `local` option - Throws if the `latest` tag is specified for a prerelease version

Andrew Clark committed Feb 13, 2018 at 11:44 UTC 1fd205ad2d101f441622c9bb7e2ccb480281e0a0
6 files changed +51 -10
scripts/release/build-commands/check-circle-ci-status.js
+3
@@ -43,5 +43,8 @@ const check = async ({cwd}) => {
43 };
44
45 module.exports = async params => {
46 + if (params.local) {
47 + return;
48 + }
49 return logPromise(check(params), 'Checking CircleCI status');
50 };
scripts/release/build-commands/update-git.js
+13 -7
@@ -6,15 +6,21 @@ const chalk = require('chalk');
6 const {exec} = require('child-process-promise');
7 const {logPromise} = require('../utils');
8
9 -const update = async ({cwd}) => {
10 - await exec('git fetch', {cwd});
11 - await exec('git checkout master', {cwd});
12 - await exec('git pull', {cwd});
9 +const update = async ({cwd, branch, local}) => {
10 + if (!local) {
11 + await exec('git fetch', {cwd});
12 + }
13 + await exec(`git checkout ${branch}`, {cwd});
14 + if (!local) {
15 + await exec('git pull', {cwd});
16 + }
17 };
18
15 -module.exports = async ({cwd}) => {
19 +module.exports = async params => {
20 return logPromise(
17 - update({cwd}),
18 - `Updating checkout ${chalk.yellow.bold(cwd)}`
21 + update(params),
22 + `Updating checkout ${chalk.yellow.bold(
23 + params.cwd
24 + )} on branch ${chalk.yellow.bold(params.branch)}}`
25 );
26 };
scripts/release/config.js
+20
@@ -23,6 +23,26 @@ const paramDefinitions = [
23 alias: 'v',
24 description: 'Semantic version number',
25 },
26 + {
27 + name: 'branch',
28 + type: String,
29 + alias: 'b',
30 + description: 'Branch to build from; defaults to [bold]{master}',
31 + defaultValue: 'master',
32 + },
33 + {
34 + name: 'local',
35 + type: Boolean,
36 + description:
37 + "Don't push or pull changes from remote repo. Don't check CI status.",
38 + },
39 + {
40 + name: 'tag',
41 + type: String,
42 + description:
43 + 'The npm dist tag; defaults to [bold]{latest} for a stable' +
44 + 'release, [bold]{next} for unstable',
45 + },
46 ];
47
48 module.exports = {
scripts/release/publish-commands/check-build-status.js
+4 -1
@@ -7,7 +7,10 @@ const {existsSync} = require('fs');
7 const {readJson} = require('fs-extra');
8 const {join} = require('path');
9
10 -module.exports = async ({cwd, version}) => {
10 +module.exports = async ({cwd, version, local}) => {
11 + if (local) {
12 + return;
13 + }
14 const packagePath = join(
15 cwd,
16 'build',
scripts/release/publish-commands/publish-to-npm.js
+8 -2
@@ -8,10 +8,16 @@ const {join} = require('path');
8 const semver = require('semver');
9 const {execRead, execUnlessDry, logPromise} = require('../utils');
10
11 -const push = async ({cwd, dry, packages, version}) => {
11 +const push = async ({cwd, dry, packages, version, tag}) => {
12 const errors = [];
13 const isPrerelease = semver.prerelease(version);
14 - const tag = isPrerelease ? 'next' : 'latest';
14 + if (tag === undefined) {
15 + // No tag was provided. Default to `latest` for stable releases and `next`
16 + // for prereleases
17 + tag = isPrerelease ? 'next' : 'latest';
18 + } else if (tag === 'latest' && isPrerelease) {
19 + throw new Error('The tag `latest` can only be used for stable versions.');
20 + }
21
22 const publishProject = async project => {
23 try {
scripts/release/publish-commands/push-git-remote.js
+3
@@ -10,5 +10,8 @@ const push = async ({cwd, dry}) => {
10 };
11
12 module.exports = async params => {
13 + if (params.local) {
14 + return;
15 + }
16 return logPromise(push(params), 'Pushing to git remote');
17 };