Skip to content

Commit 3175a22

Browse files
authored
[release] use backport NPM dist tag for backports (#79538)
### Why? When backport releases are published, they are marked as `latest` dist tag, which makes `next@latest` not the "latest." x-ref: [slack thread](https://vercel.slack.com/archives/C04LGE5SYEB/p1747984846615469) ### How? Use `stable` dist tag for backports.
1 parent 2219ba0 commit 3175a22

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

scripts/release/publish-npm.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,11 @@ async function fetchTagsFromRegistry(packageName: string) {
1515
async function getTag({
1616
name,
1717
version,
18+
latest,
1819
}: {
1920
name: string
2021
version: string
22+
latest: string
2123
}): Promise<string> {
2224
const preConfigPath = join(process.cwd(), '.changeset', 'pre.json')
2325

@@ -40,6 +42,17 @@ async function getTag({
4042
)
4143
}
4244

45+
// If the current version is less than the latest,
46+
// it means this is a backport release. Since NPM
47+
// sets the 'latest' tag by default during publishing,
48+
// when users install `next@latest`, they might get the
49+
// backported version instead of the actual "latest"
50+
// version. Hence, we explicitly set the tag as
51+
// 'stable' for backports.
52+
if (semver.lt(version, latest)) {
53+
return 'stable'
54+
}
55+
4356
return 'latest'
4457
}
4558

@@ -82,6 +95,7 @@ async function publishNpm() {
8295
const tag = await getTag({
8396
name: pkgJson.name,
8497
version: pkgJson.version,
98+
latest: tags.latest,
8599
})
86100

87101
const packagePath = join(packagesDir, packageDir.name)

0 commit comments

Comments
 (0)