@@ -59,7 +59,8 @@ if (!branch) {
5959 throw new Error ( "--branch is required" ) ;
6060}
6161
62- let isLatest = branch === "main" ;
62+ let shouldTagGithubReleaseAsLatest = branch === "main" ;
63+ let shouldUseVersion7NpmTag = branch === "v7" ;
6364
6465interface PublishedPackage {
6566 packageName : string ;
@@ -195,16 +196,26 @@ async function main() {
195196 // Publish packages to npm
196197 console . log ( "Publishing packages to npm...\n" ) ;
197198
198- // Single-phase publish: everything as latest
199- let publishCommand =
200- 'pnpm publish --recursive --filter "./packages/*" --access public --no-git-checks --report-summary' ;
199+ let args = `--access public --no-git-checks --report-summary` ;
200+ let publishCommands = shouldUseVersion7NpmTag
201+ ? // Two-phase publish:
202+ // - everything except `react-router-dom` as `version-7`
203+ // - `react-router-dom` as `latest` because it was dropped in v8
204+ [
205+ `pnpm publish --recursive --filter "./packages/*" --filter "!react-router-dom" --tag version-7 ${ args } ` ,
206+ `pnpm publish --recursive --filter react-router-dom ${ args } ` ,
207+ ]
208+ : // Single-phase publish: everything as latest
209+ [ `pnpm publish --recursive --filter "./packages/*" ${ args } ` ] ;
201210
202211 // In dry run mode, query npm to determine what would be published
203212 // and preview the GitHub releases. This is designed to be run against
204213 // the contents of the "Release" PR / `pnpm changes:version` output.
205214 if ( dryRun ) {
206215 console . log ( "Would run:" ) ;
207- console . log ( ` $ ${ publishCommand } ` ) ;
216+ for ( let publishCommand of publishCommands ) {
217+ console . log ( ` $ ${ publishCommand } ` ) ;
218+ }
208219 console . log ( ) ;
209220
210221 console . log ( "Checking npm for unpublished versions...\n" ) ;
@@ -251,8 +262,10 @@ async function main() {
251262 }
252263
253264 // Publish to npm
254- logAndExec ( publishCommand ) ;
255- let published = readPublishSummary ( ) ;
265+ let published = publishCommands . flatMap ( ( publishCommand ) => {
266+ logAndExec ( publishCommand ) ;
267+ return readPublishSummary ( ) ;
268+ } ) ;
256269
257270 if ( published . length === 0 ) {
258271 console . log ( "\nNo packages were published." ) ;
@@ -305,7 +318,7 @@ async function main() {
305318 pkg . packageName ,
306319 pkg . version ,
307320 getGithubReleaseBody ( pkg . version ) ,
308- { makeLatest : isLatest } ,
321+ { makeLatest : shouldTagGithubReleaseAsLatest } ,
309322 ) ;
310323 if ( result . status === "created" ) {
311324 console . log ( ` ✓ ${ pkg . packageName } v${ pkg . version } ` ) ;
0 commit comments