Skip to content

[release] use backport NPM dist tag for backports #79538

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

Open
wants to merge 3 commits into
base: jiwon/05-23-_release_fix_correctly_set_tag_during_publish
Choose a base branch
from
Open
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
14 changes: 14 additions & 0 deletions scripts/release/publish-npm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,11 @@ async function fetchTagsFromRegistry(packageName: string) {
async function getTag({
name,
version,
latest,
}: {
name: string
version: string
latest: string
}): Promise<string> {
const preConfigPath = join(process.cwd(), '.changeset', 'pre.json')

Expand All @@ -40,6 +42,17 @@ async function getTag({
)
}

// If the current version is less than the latest,
// it means this is a backport release. Since NPM
// sets the 'latest' tag by default during publishing,
// when users install `next@latest`, they might get the
// backported version instead of the actual "latest"
// version. Hence, we explicitly set the tag as
// 'stable' for backports.
if (semver.lt(version, latest)) {
return 'stable'
}

return 'latest'
}

Expand Down Expand Up @@ -82,6 +95,7 @@ async function publishNpm() {
const tag = await getTag({
name: pkgJson.name,
version: pkgJson.version,
latest: tags.latest,
})

const packagePath = join(packagesDir, packageDir.name)
Expand Down
Loading