Skip to content

Commit f9533d2

Browse files
committed
Avoid tagging v6 releases with latest/pre
1 parent 1e00f95 commit f9533d2

File tree

1 file changed

+32
-15
lines changed

1 file changed

+32
-15
lines changed

scripts/publish.js

Lines changed: 32 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -40,13 +40,22 @@ async function ensureBuildVersion(packageName, version) {
4040
* @param {string} packageName
4141
* @param {string} tag
4242
*/
43-
function publishBuild(packageName, tag) {
43+
function publishBuild(packageName, tag, releaseBranch) {
4444
let buildDir = path.join(rootDir, "packages", packageName);
45-
let args = ["--access public", `--tag ${tag}`];
46-
if (tag === "experimental") {
47-
args.push(`--no-git-checks`);
45+
46+
let args = ["--access public"];
47+
if (tag) {
48+
args.push(`--tag ${tag}`);
49+
}
50+
51+
if (tag === "experimental" || tag === "nightly") {
52+
args.push("--no-git-checks");
53+
} else if (releaseBranch) {
54+
args.push(`--publish-branch ${releaseBranch}`);
4855
} else {
49-
args.push("--publish-branch release-next");
56+
throw new Error(
57+
"Expected a release branch name to be provided for non-experimental/nightly releases"
58+
);
5059
}
5160
console.log();
5261
console.log(` pnpm publish ${buildDir} --tag ${tag} --access public`);
@@ -75,11 +84,19 @@ async function run() {
7584
);
7685

7786
// 2. Determine the appropriate npm tag to use
78-
let tag = version.includes("experimental")
79-
? "experimental"
80-
: semver.prerelease(version) == null
81-
? "latest"
82-
: "pre";
87+
let publishBranch;
88+
let tag;
89+
if (version.includes("experimental")) {
90+
tag = "experimental";
91+
} else if (version.includes("nightly")) {
92+
tag = "nightly";
93+
} else if (version.startsWith("6.")) {
94+
publishBranch = "release-v6";
95+
tag = null;
96+
} else if (version.startsWith("7.")) {
97+
publishBranch = "release-next";
98+
tag = semver.prerelease(version) == null ? "latest" : "pre";
99+
}
83100

84101
console.log();
85102
console.log(` Publishing version ${version} to npm with tag "${tag}"`);
@@ -96,11 +113,11 @@ async function run() {
96113
await ensureBuildVersion("react-router-native", version);
97114

98115
// 4. Publish to npm
99-
publishBuild("router", tag);
100-
publishBuild("react-router", tag);
101-
publishBuild("react-router-dom", tag);
102-
publishBuild("react-router-dom-v5-compat", tag);
103-
publishBuild("react-router-native", tag);
116+
publishBuild("router", tag, publishBranch);
117+
publishBuild("react-router", tag, publishBranch);
118+
publishBuild("react-router-dom", tag, publishBranch);
119+
publishBuild("react-router-dom-v5-compat", tag, publishBranch);
120+
publishBuild("react-router-native", tag, publishBranch);
104121
} catch (error) {
105122
console.log();
106123
console.error(` ${error.message}`);

0 commit comments

Comments
 (0)