Skip to content

Commit

Permalink
Additional release script options for publishing canary versions (#12219
Browse files Browse the repository at this point in the history
)

* 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
  • Loading branch information
acdlite committed Feb 13, 2018
1 parent e2563a3 commit 1fd205a
Show file tree
Hide file tree
Showing 6 changed files with 51 additions and 10 deletions.
3 changes: 3 additions & 0 deletions scripts/release/build-commands/check-circle-ci-status.js
Expand Up @@ -43,5 +43,8 @@ const check = async ({cwd}) => {
};

module.exports = async params => {
if (params.local) {
return;
}
return logPromise(check(params), 'Checking CircleCI status');
};
20 changes: 13 additions & 7 deletions scripts/release/build-commands/update-git.js
Expand Up @@ -6,15 +6,21 @@ const chalk = require('chalk');
const {exec} = require('child-process-promise');
const {logPromise} = require('../utils');

const update = async ({cwd}) => {
await exec('git fetch', {cwd});
await exec('git checkout master', {cwd});
await exec('git pull', {cwd});
const update = async ({cwd, branch, local}) => {
if (!local) {
await exec('git fetch', {cwd});
}
await exec(`git checkout ${branch}`, {cwd});
if (!local) {
await exec('git pull', {cwd});
}
};

module.exports = async ({cwd}) => {
module.exports = async params => {
return logPromise(
update({cwd}),
`Updating checkout ${chalk.yellow.bold(cwd)}`
update(params),
`Updating checkout ${chalk.yellow.bold(
params.cwd
)} on branch ${chalk.yellow.bold(params.branch)}}`
);
};
20 changes: 20 additions & 0 deletions scripts/release/config.js
Expand Up @@ -23,6 +23,26 @@ const paramDefinitions = [
alias: 'v',
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 push or pull changes from remote repo. Don't check CI status.",
},
{
name: 'tag',
type: String,
description:
'The npm dist tag; defaults to [bold]{latest} for a stable' +
'release, [bold]{next} for unstable',
},
];

module.exports = {
Expand Down
5 changes: 4 additions & 1 deletion scripts/release/publish-commands/check-build-status.js
Expand Up @@ -7,7 +7,10 @@ const {existsSync} = require('fs');
const {readJson} = require('fs-extra');
const {join} = require('path');

module.exports = async ({cwd, version}) => {
module.exports = async ({cwd, version, local}) => {
if (local) {
return;
}
const packagePath = join(
cwd,
'build',
Expand Down
10 changes: 8 additions & 2 deletions scripts/release/publish-commands/publish-to-npm.js
Expand Up @@ -8,10 +8,16 @@ const {join} = require('path');
const semver = require('semver');
const {execRead, execUnlessDry, logPromise} = require('../utils');

const push = async ({cwd, dry, packages, version}) => {
const push = async ({cwd, dry, packages, version, tag}) => {
const errors = [];
const isPrerelease = semver.prerelease(version);
const tag = isPrerelease ? 'next' : 'latest';
if (tag === undefined) {
// No tag was provided. Default to `latest` for stable releases and `next`
// for prereleases
tag = isPrerelease ? 'next' : 'latest';
} else if (tag === 'latest' && isPrerelease) {
throw new Error('The tag `latest` can only be used for stable versions.');
}

const publishProject = async project => {
try {
Expand Down
3 changes: 3 additions & 0 deletions scripts/release/publish-commands/push-git-remote.js
Expand Up @@ -10,5 +10,8 @@ const push = async ({cwd, dry}) => {
};

module.exports = async params => {
if (params.local) {
return;
}
return logPromise(push(params), 'Pushing to git remote');
};

0 comments on commit 1fd205a

Please sign in to comment.