Release script supports interleaved stable and alpha releases (#14138)
Brian Vaughn committed
Nov 7, 2018 at 12:33 UTC
be63473004748d2f2360eb08f90dd08a19252a71
1 file changed
+8
-4
scripts/release/publish-commands/publish-to-npm.js
+8
-4
@@ -11,10 +11,12 @@ const {execRead, execUnlessDry, logPromise} = require('../utils');
11
const push = async ({cwd, dry, otp, packages, version, tag}) => {
12
const errors = [];
13
const isPrerelease = semver.prerelease(version);
14
+
15
+ let resolvedTag = tag;
16
if (tag === undefined) {
17
// No tag was provided. Default to `latest` for stable releases and `next`
18
// for prereleases
17
- tag = isPrerelease ? 'next' : 'latest';
19
+ resolvedTag = isPrerelease ? 'next' : 'latest';
20
} else if (tag === 'latest' && isPrerelease) {
21
throw new Error('The tag `latest` can only be used for stable versions.');
22
}
@@ -26,7 +28,7 @@ const push = async ({cwd, dry, otp, packages, version, tag}) => {
28
const publishProject = async project => {
29
try {
30
const path = join(cwd, 'build', 'node_modules', project);
29
- await execUnlessDry(`npm publish --tag ${tag} ${twoFactorAuth}`, {
31
+ await execUnlessDry(`npm publish --tag ${resolvedTag} ${twoFactorAuth}`, {
32
cwd: path,
33
dry,
34
});
@@ -49,7 +51,7 @@ const push = async ({cwd, dry, otp, packages, version, tag}) => {
51
const status = JSON.parse(
52
await execRead(`npm info ${project} dist-tags --json`)
53
);
52
- const remoteVersion = status[tag];
54
+ const remoteVersion = status[resolvedTag];
55
56
// Compare remote version to package.json version,
57
// To better handle the case of pre-release versions.
@@ -62,7 +64,9 @@ const push = async ({cwd, dry, otp, packages, version, tag}) => {
64
65
// If we've just published a stable release,
66
// Update the @next tag to also point to it (so @next doesn't lag behind).
65
- if (!isPrerelease) {
67
+ // Skip this step if we have a manually specified tag.
68
+ // This is an escape hatch for us to interleave alpha and stable releases.
69
+ if (tag === undefined && !isPrerelease) {
70
await execUnlessDry(
71
`npm dist-tag add ${project}@${packageVersion} next ${twoFactorAuth}`,
72
{cwd: path, dry}