Skip to content

Commit 1fd205a

Browse files
authored
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
1 parent e2563a3 commit 1fd205a

File tree

6 files changed

+51
-10
lines changed

6 files changed

+51
-10
lines changed

scripts/release/build-commands/check-circle-ci-status.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,5 +43,8 @@ const check = async ({cwd}) => {
4343
};
4444

4545
module.exports = async params => {
46+
if (params.local) {
47+
return;
48+
}
4649
return logPromise(check(params), 'Checking CircleCI status');
4750
};

scripts/release/build-commands/update-git.js

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,21 @@ const chalk = require('chalk');
66
const {exec} = require('child-process-promise');
77
const {logPromise} = require('../utils');
88

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+
}
1317
};
1418

15-
module.exports = async ({cwd}) => {
19+
module.exports = async params => {
1620
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)}}`
1925
);
2026
};

scripts/release/config.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,26 @@ const paramDefinitions = [
2323
alias: 'v',
2424
description: 'Semantic version number',
2525
},
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+
},
2646
];
2747

2848
module.exports = {

scripts/release/publish-commands/check-build-status.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,10 @@ const {existsSync} = require('fs');
77
const {readJson} = require('fs-extra');
88
const {join} = require('path');
99

10-
module.exports = async ({cwd, version}) => {
10+
module.exports = async ({cwd, version, local}) => {
11+
if (local) {
12+
return;
13+
}
1114
const packagePath = join(
1215
cwd,
1316
'build',

scripts/release/publish-commands/publish-to-npm.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,16 @@ const {join} = require('path');
88
const semver = require('semver');
99
const {execRead, execUnlessDry, logPromise} = require('../utils');
1010

11-
const push = async ({cwd, dry, packages, version}) => {
11+
const push = async ({cwd, dry, packages, version, tag}) => {
1212
const errors = [];
1313
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+
}
1521

1622
const publishProject = async project => {
1723
try {

scripts/release/publish-commands/push-git-remote.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,8 @@ const push = async ({cwd, dry}) => {
1010
};
1111

1212
module.exports = async params => {
13+
if (params.local) {
14+
return;
15+
}
1316
return logPromise(push(params), 'Pushing to git remote');
1417
};

0 commit comments

Comments
 (0)