Skip to content

Release script supports interleaved stable and alpha releases #14138

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 7, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions scripts/release/publish-commands/publish-to-npm.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,12 @@ const {execRead, execUnlessDry, logPromise} = require('../utils');
const push = async ({cwd, dry, otp, packages, version, tag}) => {
const errors = [];
const isPrerelease = semver.prerelease(version);

let resolvedTag = tag;
if (tag === undefined) {
// No tag was provided. Default to `latest` for stable releases and `next`
// for prereleases
tag = isPrerelease ? 'next' : 'latest';
resolvedTag = isPrerelease ? 'next' : 'latest';
} else if (tag === 'latest' && isPrerelease) {
throw new Error('The tag `latest` can only be used for stable versions.');
}
Expand All @@ -26,7 +28,7 @@ const push = async ({cwd, dry, otp, packages, version, tag}) => {
const publishProject = async project => {
try {
const path = join(cwd, 'build', 'node_modules', project);
await execUnlessDry(`npm publish --tag ${tag} ${twoFactorAuth}`, {
await execUnlessDry(`npm publish --tag ${resolvedTag} ${twoFactorAuth}`, {
cwd: path,
dry,
});
Expand All @@ -49,7 +51,7 @@ const push = async ({cwd, dry, otp, packages, version, tag}) => {
const status = JSON.parse(
await execRead(`npm info ${project} dist-tags --json`)
);
const remoteVersion = status[tag];
const remoteVersion = status[resolvedTag];

// Compare remote version to package.json version,
// To better handle the case of pre-release versions.
Expand All @@ -62,7 +64,9 @@ const push = async ({cwd, dry, otp, packages, version, tag}) => {

// If we've just published a stable release,
// Update the @next tag to also point to it (so @next doesn't lag behind).
if (!isPrerelease) {
// Skip this step if we have a manually specified tag.
// This is an escape hatch for us to interleave alpha and stable releases.
if (tag === undefined && !isPrerelease) {
await execUnlessDry(
`npm dist-tag add ${project}@${packageVersion} next ${twoFactorAuth}`,
{cwd: path, dry}
Expand Down