Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
N
next.js
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Alex
next.js
Commits
23cd9246
Unverified
Commit
23cd9246
authored
Jun 09, 2026
by
Sebastian "Sebbie" Silbermann
Committed by
GitHub
Jun 09, 2026
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[cd] Publish preview release with `@preview` NPM dist-tag (#94619)
parent
db6f8645
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
73 additions
and
3 deletions
+73
-3
publish-native.js
scripts/publish-native.js
+67
-1
publish-release.js
scripts/publish-release.js
+6
-2
No files found.
scripts/publish-native.js
View file @
23cd9246
...
@@ -2,17 +2,82 @@
...
@@ -2,17 +2,82 @@
const
path
=
require
(
'path'
)
const
path
=
require
(
'path'
)
const
execa
=
require
(
'execa'
)
const
execa
=
require
(
'execa'
)
const
semver
=
require
(
'semver'
)
const
{
Sema
}
=
require
(
'async-sema'
)
const
{
Sema
}
=
require
(
'async-sema'
)
const
{
execSync
}
=
require
(
'child_process'
)
const
fs
=
require
(
'fs'
)
const
{
readFile
,
readdir
,
writeFile
,
cp
}
=
require
(
'fs/promises'
)
const
{
readFile
,
readdir
,
writeFile
,
cp
}
=
require
(
'fs/promises'
)
const
cwd
=
process
.
cwd
()
const
cwd
=
process
.
cwd
()
;(
async
function
()
{
;(
async
function
()
{
let
isCanary
=
true
let
isReleaseCandidate
=
false
let
isBeta
=
false
let
isPreview
=
false
try
{
const
tagOutput
=
execSync
(
`node
${
path
.
join
(
__dirname
,
'check-is-release.js'
)}
`
).
toString
()
console
.
log
(
tagOutput
)
if
(
tagOutput
.
trim
().
startsWith
(
'v'
))
{
isCanary
=
tagOutput
.
includes
(
'-canary'
)
}
isReleaseCandidate
=
tagOutput
.
includes
(
'-rc'
)
isBeta
=
tagOutput
.
includes
(
'-beta'
)
isPreview
=
tagOutput
.
includes
(
'-preview'
)
}
catch
(
err
)
{
console
.
log
(
err
)
if
(
err
.
message
&&
err
.
message
.
includes
(
'no tag exactly matches'
))
{
console
.
log
(
'Nothing to publish, exiting...'
)
return
}
throw
err
}
try
{
try
{
const
publishSema
=
new
Sema
(
2
)
const
publishSema
=
new
Sema
(
2
)
let
version
=
require
(
'@next/swc/package.json'
).
version
let
version
=
require
(
'@next/swc/package.json'
).
version
let
tag
=
isCanary
?
'canary'
:
isReleaseCandidate
?
'rc'
:
isBeta
?
'beta'
:
isPreview
?
'preview'
:
'latest'
try
{
if
(
!
isCanary
&&
!
isReleaseCandidate
&&
!
isBeta
&&
!
isPreview
)
{
const
version
=
JSON
.
parse
(
await
fs
.
promises
.
readFile
(
path
.
join
(
cwd
,
'lerna.json'
),
'utf-8'
)
).
version
const
res
=
await
fetch
(
`https://registry.npmjs.org/-/package/next/dist-tags`
)
const
tags
=
await
res
.
json
()
if
(
semver
.
lt
(
version
,
tags
.
latest
))
{
// 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.
// Therefore, we explicitly set the tag as 'backport' for backports.
tag
=
'backport'
}
}
}
catch
(
error
)
{
console
.
log
(
'Failed to fetch Next.js dist tags from the NPM registry.'
)
throw
error
}
// Copy binaries to package folders, update version, and publish
// Copy binaries to package folders, update version, and publish
let
nativePackagesDir
=
path
.
join
(
cwd
,
'crates/next-napi-bindings/npm'
)
let
nativePackagesDir
=
path
.
join
(
cwd
,
'crates/next-napi-bindings/npm'
)
let
platforms
=
(
await
readdir
(
nativePackagesDir
)).
filter
(
let
platforms
=
(
await
readdir
(
nativePackagesDir
)).
filter
(
...
@@ -47,7 +112,8 @@ const cwd = process.cwd()
...
@@ -47,7 +112,8 @@ const cwd = process.cwd()
`
${
path
.
join
(
nativePackagesDir
,
platform
)}
`
,
`
${
path
.
join
(
nativePackagesDir
,
platform
)}
`
,
`--access`
,
`--access`
,
`public`
,
`public`
,
...(
version
.
includes
(
'canary'
)
?
[
'--tag'
,
'canary'
]
:
[]),
'--tag'
,
tag
,
],
],
{
stdio
:
'inherit'
}
{
stdio
:
'inherit'
}
)
)
...
...
scripts/publish-release.js
View file @
23cd9246
...
@@ -18,6 +18,7 @@ const cwd = process.cwd()
...
@@ -18,6 +18,7 @@ const cwd = process.cwd()
let
isCanary
=
true
let
isCanary
=
true
let
isReleaseCandidate
=
false
let
isReleaseCandidate
=
false
let
isBeta
=
false
let
isBeta
=
false
let
isPreview
=
false
try
{
try
{
const
tagOutput
=
execSync
(
const
tagOutput
=
execSync
(
...
@@ -30,6 +31,7 @@ const cwd = process.cwd()
...
@@ -30,6 +31,7 @@ const cwd = process.cwd()
}
}
isReleaseCandidate
=
tagOutput
.
includes
(
'-rc'
)
isReleaseCandidate
=
tagOutput
.
includes
(
'-rc'
)
isBeta
=
tagOutput
.
includes
(
'-beta'
)
isBeta
=
tagOutput
.
includes
(
'-beta'
)
isPreview
=
tagOutput
.
includes
(
'-preview'
)
}
catch
(
err
)
{
}
catch
(
err
)
{
console
.
log
(
err
)
console
.
log
(
err
)
...
@@ -46,10 +48,12 @@ const cwd = process.cwd()
...
@@ -46,10 +48,12 @@ const cwd = process.cwd()
?
'rc'
?
'rc'
:
isBeta
:
isBeta
?
'beta'
?
'beta'
:
'latest'
:
isPreview
?
'preview'
:
'latest'
try
{
try
{
if
(
!
isCanary
&&
!
isReleaseCandidate
&&
!
isBeta
)
{
if
(
!
isCanary
&&
!
isReleaseCandidate
&&
!
isBeta
&&
!
isPreview
)
{
const
version
=
JSON
.
parse
(
const
version
=
JSON
.
parse
(
await
fs
.
promises
.
readFile
(
path
.
join
(
cwd
,
'lerna.json'
),
'utf-8'
)
await
fs
.
promises
.
readFile
(
path
.
join
(
cwd
,
'lerna.json'
),
'utf-8'
)
).
version
).
version
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment