chore(scripts): update release script to include tag for rc

- adds support for changing the tag from `latest` to `next`
- checks the user's confirmation on the prepare and tag to end the script if the user selects no
- adds support for passing --dry-run to see what the publish will be
This commit is contained in:
Brandy Carney
2019-10-11 12:59:08 -04:00
parent 2f882373bf
commit 94c13c2994
4 changed files with 62 additions and 8 deletions

2
.github/PROCESS.md vendored
View File

@@ -240,6 +240,8 @@ Hotfixes bypass `master` and should only be used for urgent fixes that can't wai
- For major or minor releases, ensure that the version number has an associated title (for example: `4.5.0 Boron`)
- Commit these changes with the version number as the message, e.g. `git commit -m "4.5.0"`
1. *(Optional)* Run `npm run release -- --dry-run` to run the release without publishing and verify the version.
1. Run `npm run release`
1. Click **Merge pull request**. Use the dropdown to select this option if necessary.

View File

@@ -1,6 +1,7 @@
const fs = require('fs-extra');
const path = require('path');
const execa = require('execa');
const inquirer = require('inquirer');
const Listr = require('listr');
const semver = require('semver');
const tc = require('turbocolor');
@@ -34,6 +35,34 @@ function projectPath(project) {
return path.join(rootDir, project);
}
async function askTag() {
const prompts = [
{
type: 'list',
name: 'tag',
message: 'Select npm tag or specify a new tag',
choices: ['latest', 'next']
.concat([
new inquirer.Separator(),
{
name: 'Other (specify)',
value: null
}
])
},
{
type: 'confirm',
name: 'confirm',
message: answers => {
return `Will publish to ${tc.cyan(answers.tag)}. Continue?`;
}
}
];
const { tag, confirm } = await inquirer.prompt(prompts);
return { tag, confirm };
}
function checkGit(tasks) {
tasks.push(
{
@@ -300,6 +329,7 @@ function copyCDNLoader(tasks, version) {
module.exports = {
checkTestDist,
checkGit,
askTag,
isValidVersion,
isVersionGreater,
copyCDNLoader,

View File

@@ -17,9 +17,13 @@ async function main() {
throw new Error('env.GH_TOKEN is undefined');
}
const version = await askVersion();
const { version, confirm } = await askVersion();
const install = process.argv.indexOf('--no-install') < 0;
if (!confirm) {
return;
}
// compile and verify packages
await preparePackages(common.packages, version, install);
@@ -85,8 +89,8 @@ async function askVersion() {
}
];
const {version} = await inquirer.prompt(prompts);
return version;
const { version, confirm } = await inquirer.prompt(prompts);
return { version, confirm };
}

View File

@@ -13,6 +13,8 @@ const fs = require('fs-extra');
async function main() {
try {
const dryRun = process.argv.indexOf('--dry-run') > -1;
if (!process.env.GH_TOKEN) {
throw new Error('env.GH_TOKEN is undefined');
}
@@ -26,15 +28,31 @@ async function main() {
// repo must be clean
common.checkGit(tasks);
// publish each package in NPM
common.publishPackages(tasks, common.packages, version);
const { tag, confirm } = await common.askTag();
// push tag to git remote
publishGit(tasks, version, changelog);
if (!confirm) {
return;
}
if(!dryRun) {
// publish each package in NPM
common.publishPackages(tasks, common.packages, version, tag);
// push tag to git remote
publishGit(tasks, version, changelog);
}
const listr = new Listr(tasks);
await listr.run();
console.log(`\nionic ${version} published!! 🎉\n`);
// Dry run doesn't publish to npm or git
if (dryRun) {
console.log(`
\n${tc.yellow('Did not publish. Remove the "--dry-run" flag to publish:')}\n${tc.green(version)} to ${tc.cyan(tag)}\n
`);
} else {
console.log(`\nionic ${version} published to ${tag}!! 🎉\n`);
}
} catch (err) {
console.log('\n', tc.red(err), '\n');