Skip to content

Commit 3554879

Browse files
authored
Revert "Support untagged releases (facebook#19507)"
This reverts commit 58b3ee7.
1 parent 58b3ee7 commit 3554879

10 files changed

+84
-117
lines changed

scripts/release/README.md

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,9 @@ The high level process of creating releases is [documented below](#process). Ind
2020

2121
If this is your first time running the release scripts, go to the `scripts/release` directory and run `yarn` to install the dependencies.
2222

23-
## Publishing Untagged
23+
## Publishing Without Tags
2424

25-
The sections bekow include meaningful `--tag` in the instructions.
26-
27-
However, keep in mind that **the `--tag` arguments is optional**, and you can omit it if you don't want to tag the release on npm at all. This can be useful when preparing breaking changes.
28-
29-
Because npm requires a tag on publish, the script does it by creating a temporary tag and deleting it afterwards.
25+
The sections bekow include meaningful `--tags` in the instructions. However, keep in mind that **the `--tags` arguments is optional**, and you can omit it if you don't want to tag the release on npm at all. This can be useful when preparing breaking changes.
3026

3127
## Publishing Next
3228

@@ -46,7 +42,7 @@ scripts/release/prepare-release-from-ci.js --build=124756
4642

4743
Once the build has been checked out and tested locally, you're ready to publish it:
4844
```sh
49-
scripts/release/publish.js --tag next
45+
scripts/release/publish.js --tags next
5046
```
5147

5248
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.
@@ -68,7 +64,7 @@ scripts/release/prepare-release-from-ci.js --build=124763
6864
Once the build has been checked out and tested locally, you're ready to publish it. When publishing an experimental release, use the `experimental` tag:
6965

7066
```sh
71-
scripts/release/publish.js --tag experimental
67+
scripts/release/publish.js --tags experimental
7268
```
7369

7470
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.
@@ -90,13 +86,11 @@ This script will prompt you to select stable version numbers for each of the pac
9086
Once this step is complete, you're ready to publish the release:
9187

9288
```sh
93-
scripts/release/publish.js --tag latest
89+
scripts/release/publish.js --tags latest
9490
```
9591

9692
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.
9793

98-
Note that publishing the `latest` tag will always update the `next` tag automatically as well so they're in sync.
99-
10094
After successfully publishing the release, follow the on-screen instructions to ensure that all of the appropriate post-release steps are executed.
10195

10296
<sup>1: You can omit the `version` param if you just want to promote the latest "next" candidate to stable.</sup>
@@ -176,9 +170,7 @@ Upon completion, this script provides instructions for tagging the Git commit th
176170
**Specify a `--dry` flag when running this script if you want to skip the NPM-publish step.** In this event, the script will print the NPM commands but it will not actually run them.
177171

178172
#### Example usage
179-
To publish a release to NPM as `latest`:
173+
To publish a release to NPM as both `next` and `latest`:
180174
```sh
181-
scripts/release/publish.js --tag latest
175+
scripts/release/publish.js --tags latest
182176
```
183-
184-
Note that publishing the `latest` tag will always update the `next` tag automatically as well so they're in sync.

scripts/release/publish-commands/confirm-skipped-packages.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ const clear = require('clear');
66
const {confirm} = require('../utils');
77
const theme = require('../theme');
88

9-
const run = async ({cwd, packages, skipPackages}) => {
9+
const run = async ({cwd, packages, skipPackages, tags}) => {
1010
if (skipPackages.length === 0) {
1111
return;
1212
}

scripts/release/publish-commands/confirm-version-and-tag.js renamed to scripts/release/publish-commands/confirm-version-and-tags.js

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,24 @@ const {join} = require('path');
88
const {confirm} = require('../utils');
99
const theme = require('../theme');
1010

11-
const run = async ({cwd, packages, tag}) => {
11+
const run = async ({cwd, packages, tags}) => {
1212
clear();
1313

14-
// All latest releases are auto-tagged as next too by the script.
15-
let tags = tag === 'latest' ? ['latest', 'next'] : [tag];
16-
console.log(
17-
theme`{spinnerSuccess ✓} You are about the publish the following packages under the tag {tag ${tags.join(
18-
', '
19-
)}}:`
20-
);
14+
if (tags.length === 0) {
15+
console.log(
16+
theme`{spinnerSuccess ✓} You are about the publish the following packages without any tags:`
17+
);
18+
} else if (tags.length === 1) {
19+
console.log(
20+
theme`{spinnerSuccess ✓} You are about the publish the following packages under the tag {tag ${tags}}:`
21+
);
22+
} else {
23+
console.log(
24+
theme`{spinnerSuccess ✓} You are about the publish the following packages under the tags {tag ${tags.join(
25+
', '
26+
)}}:`
27+
);
28+
}
2129

2230
for (let i = 0; i < packages.length; i++) {
2331
const packageName = packages[i];

scripts/release/publish-commands/parse-params.js

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@ const paramDefinitions = [
1313
defaultValue: false,
1414
},
1515
{
16-
name: 'tag',
16+
name: 'tags',
1717
type: String,
18-
description: 'NPM tag to point to the new release.',
19-
defaultValue: 'untagged',
18+
multiple: true,
19+
description: 'NPM tags to point to the new release.',
2020
},
2121
{
2222
name: 'skipPackages',
@@ -29,17 +29,10 @@ const paramDefinitions = [
2929

3030
module.exports = () => {
3131
const params = commandLineArgs(paramDefinitions);
32-
switch (params.tag) {
33-
case 'latest':
34-
case 'next':
35-
case 'experimental':
36-
case 'untagged':
37-
break;
38-
default:
39-
console.error('Unknown tag: "' + params.tag + '"');
40-
process.exit(1);
41-
break;
32+
if (!params.tags || !params.tags.length) {
33+
params.tags = [];
4234
}
4335
splitCommaParams(params.skipPackages);
36+
splitCommaParams(params.tags);
4437
return params;
4538
};

scripts/release/publish-commands/print-follow-up-instructions.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ const {join} = require('path');
99
const theme = require('../theme');
1010
const {execRead} = require('../utils');
1111

12-
const run = async ({cwd, packages, tag}) => {
12+
const run = async ({cwd, packages, tags}) => {
1313
// All packages are built from a single source revision,
1414
// so it is safe to read build info from any one of them.
1515
const arbitraryPackageName = packages[0];
@@ -24,7 +24,7 @@ const run = async ({cwd, packages, tag}) => {
2424

2525
clear();
2626

27-
if (tag === 'next') {
27+
if (tags.length === 1 && tags[0] === 'next') {
2828
console.log(
2929
theme`{header A "next" release} {version ${version}} {header has been published!}`
3030
);
@@ -35,7 +35,7 @@ const run = async ({cwd, packages, tag}) => {
3535
theme.caution`The release has been published but you're not done yet!`
3636
);
3737

38-
if (tag === 'latest') {
38+
if (tags.includes('latest')) {
3939
console.log();
4040
console.log(
4141
theme.header`Please review and commit all local, staged changes.`

scripts/release/publish-commands/publish-to-npm.js

Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ const {join} = require('path');
99
const {confirm, execRead} = require('../utils');
1010
const theme = require('../theme');
1111

12-
const run = async ({cwd, dry, packages, tag}, otp) => {
12+
const run = async ({cwd, dry, packages, tags}, otp) => {
1313
clear();
1414

1515
for (let i = 0; i < packages.length; i++) {
@@ -34,34 +34,25 @@ const run = async ({cwd, dry, packages, tag}, otp) => {
3434

3535
// Publish the package and tag it.
3636
if (!dry) {
37-
await exec(`npm publish --tag=${tag} --otp=${otp}`, {
37+
await exec(`npm publish --tag=${tags[0]} --otp=${otp}`, {
3838
cwd: packagePath,
3939
});
4040
}
4141
console.log(theme.command(` cd ${packagePath}`));
42-
console.log(theme.command(` npm publish --tag=${tag} --otp=${otp}`));
42+
console.log(theme.command(` npm publish --tag=${tags[0]} --otp=${otp}`));
4343

44-
if (tag === 'latest') {
45-
// Whenever we publish latest, also tag "next" automatically so they're in sync.
44+
for (let j = 1; j < tags.length; j++) {
4645
if (!dry) {
4746
await exec(
48-
`npm dist-tag add ${packageName}@${version} next --otp=${otp}`
47+
`npm dist-tag add ${packageName}@${version} ${tags[j]} --otp=${otp}`,
48+
{cwd: packagePath}
4949
);
5050
}
5151
console.log(
5252
theme.command(
53-
` npm dist-tag add ${packageName}@${version} next --otp=${otp}`
53+
` npm dist-tag add ${packageName}@${version} ${tags[j]} --otp=${otp}`
5454
)
5555
);
56-
} else if (tag === 'untagged') {
57-
// npm doesn't let us publish without a tag at all,
58-
// so for one-off publishes we clean it up ourselves.
59-
if (!dry) {
60-
await exec(`npm dist-tag rm ${packageName}@untagged --otp=${otp}`);
61-
}
62-
console.log(
63-
theme.command(`npm dist-tag rm ${packageName}@untagged --otp=${otp}`)
64-
);
6556
}
6657
}
6758
}

scripts/release/publish-commands/update-stable-version-numbers.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ const {readFileSync, writeFileSync} = require('fs');
66
const {readJson, writeJson} = require('fs-extra');
77
const {join} = require('path');
88

9-
const run = async ({cwd, packages, skipPackages, tag}) => {
10-
if (tag !== 'latest') {
9+
const run = async ({cwd, packages, skipPackages, tags}) => {
10+
if (!tags.includes('latest')) {
1111
// Don't update version numbers for alphas.
1212
return;
1313
}

scripts/release/publish-commands/validate-tag.js

Lines changed: 0 additions & 55 deletions
This file was deleted.
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
#!/usr/bin/env node
2+
3+
'use strict';
4+
5+
const {readJson} = require('fs-extra');
6+
const {join} = require('path');
7+
const theme = require('../theme');
8+
9+
const run = async ({cwd, packages, tags}) => {
10+
// Prevent a "next" release from ever being published as @latest
11+
// All canaries share a version number, so it's okay to check any of them.
12+
const arbitraryPackageName = packages[0];
13+
const packageJSONPath = join(
14+
cwd,
15+
'build',
16+
'node_modules',
17+
arbitraryPackageName,
18+
'package.json'
19+
);
20+
const {version} = await readJson(packageJSONPath);
21+
if (version.indexOf('0.0.0') === 0) {
22+
if (tags.includes('latest')) {
23+
console.log(
24+
theme`{error Next release} {version ${version}} {error cannot be tagged as} {tag latest}`
25+
);
26+
process.exit(1);
27+
}
28+
} else {
29+
if (tags.includes('next')) {
30+
console.log(
31+
theme`{error Stable release} {version ${version}} {error cannot be tagged as} {tag next}`
32+
);
33+
process.exit(1);
34+
}
35+
}
36+
};
37+
38+
module.exports = run;

scripts/release/publish.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,13 @@ const theme = require('./theme');
88

99
const checkNPMPermissions = require('./publish-commands/check-npm-permissions');
1010
const confirmSkippedPackages = require('./publish-commands/confirm-skipped-packages');
11-
const confirmVersionAndTag = require('./publish-commands/confirm-version-and-tag');
11+
const confirmVersionAndTags = require('./publish-commands/confirm-version-and-tags');
1212
const parseParams = require('./publish-commands/parse-params');
1313
const printFollowUpInstructions = require('./publish-commands/print-follow-up-instructions');
1414
const promptForOTP = require('./publish-commands/prompt-for-otp');
1515
const publishToNPM = require('./publish-commands/publish-to-npm');
1616
const updateStableVersionNumbers = require('./publish-commands/update-stable-version-numbers');
17-
const validateTag = require('./publish-commands/validate-tag');
17+
const validateTags = require('./publish-commands/validate-tags');
1818
const validateSkipPackages = require('./publish-commands/validate-skip-packages');
1919

2020
const run = async () => {
@@ -37,9 +37,9 @@ const run = async () => {
3737
}
3838
});
3939

40-
await validateTag(params);
40+
await validateTags(params);
4141
await confirmSkippedPackages(params);
42-
await confirmVersionAndTag(params);
42+
await confirmVersionAndTags(params);
4343
await validateSkipPackages(params);
4444
await checkNPMPermissions(params);
4545
const otp = await promptForOTP(params);

0 commit comments

Comments
 (0)