Skip to content

Support untagged releases #19509

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
Jul 31, 2020
Merged
Show file tree
Hide file tree
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
5 changes: 4 additions & 1 deletion scripts/release/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,9 @@ Once this step is complete, you're ready to publish the release:

```sh
scripts/release/publish.js --tags latest

# Or, if you want to bump "next" as well:
scripts/release/publish.js --tags latest next
```

If the OTP code expires while publishing, re-run this command and answer "y" to the questions about whether it was expected for already published packages.
Expand Down Expand Up @@ -172,5 +175,5 @@ Upon completion, this script provides instructions for tagging the Git commit th
#### Example usage
To publish a release to NPM as both `next` and `latest`:
```sh
scripts/release/publish.js --tags latest
scripts/release/publish.js --tags latest next
```
5 changes: 2 additions & 3 deletions scripts/release/publish-commands/confirm-version-and-tags.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,8 @@ const run = async ({cwd, packages, tags}) => {
clear();

if (tags.length === 0) {
console.log(
theme`{spinnerSuccess ✓} You are about the publish the following packages without any tags:`
);
console.error('Expected at least one tag.');
process.exit(1);
} else if (tags.length === 1) {
console.log(
theme`{spinnerSuccess ✓} You are about the publish the following packages under the tag {tag ${tags}}:`
Expand Down
17 changes: 14 additions & 3 deletions scripts/release/publish-commands/parse-params.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ const paramDefinitions = [
type: String,
multiple: true,
description: 'NPM tags to point to the new release.',
defaultValue: ['untagged'],
},
{
name: 'skipPackages',
Expand All @@ -29,10 +30,20 @@ const paramDefinitions = [

module.exports = () => {
const params = commandLineArgs(paramDefinitions);
if (!params.tags || !params.tags.length) {
params.tags = [];
}
splitCommaParams(params.skipPackages);
splitCommaParams(params.tags);
params.tags.forEach(tag => {
switch (tag) {
case 'latest':
case 'next':
case 'experimental':
case 'untagged':
break;
default:
console.error('Unknown tag: "' + params.tag + '"');
process.exit(1);
break;
}
});
return params;
};
11 changes: 11 additions & 0 deletions scripts/release/publish-commands/publish-to-npm.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,17 @@ const run = async ({cwd, dry, packages, tags}, otp) => {
)
);
}

if (tags.includes('untagged')) {
// npm doesn't let us publish without a tag at all,
// so for one-off publishes we clean it up ourselves.
if (!dry) {
await exec(`npm dist-tag rm ${packageName}@untagged --otp=${otp}`);
}
console.log(
theme.command(`npm dist-tag rm ${packageName}@untagged --otp=${otp}`)
);
}
}
}
};
Expand Down
31 changes: 28 additions & 3 deletions scripts/release/publish-commands/validate-tags.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,42 @@ const run = async ({cwd, packages, tags}) => {
'package.json'
);
const {version} = await readJson(packageJSONPath);
const isExperimentalVersion = version.indexOf('experimental') !== -1;
if (version.indexOf('0.0.0') === 0) {
if (tags.includes('latest')) {
if (isExperimentalVersion) {
console.log(
theme`{error Experimental release} {version ${version}} {error cannot be tagged as} {tag latest}`
);
} else {
console.log(
theme`{error Next release} {version ${version}} {error cannot be tagged as} {tag latest}`
);
}
process.exit(1);
}
if (tags.includes('next') && isExperimentalVersion) {
console.log(
theme`{error Experimental release} {version ${version}} {error cannot be tagged as} {tag next}`
);
process.exit(1);
}
if (tags.includes('experimental') && !isExperimentalVersion) {
console.log(
theme`{error Next release} {version ${version}} {error cannot be tagged as} {tag latest}`
theme`{error Next release} {version ${version}} {error cannot be tagged as} {tag experimental}`
);
process.exit(1);
}
} else {
if (tags.includes('next')) {
if (!tags.includes('latest')) {
console.log(
theme`{error Stable release} {version ${version}} {error must always be tagged as} {tag latest}`
);
process.exit(1);
}
if (tags.includes('experimental')) {
console.log(
theme`{error Stable release} {version ${version}} {error cannot be tagged as} {tag next}`
theme`{error Stable release} {version ${version}} {error cannot be tagged as} {tag experimental}`
);
process.exit(1);
}
Expand Down