@@ -22,7 +22,15 @@ import {
2222 * @returns {Promise<void> }
2323 */
2424export const publish = async ( options ) => {
25- const { branchConfigs, packages, rootDir, branch, tag, ghToken } = options
25+ const {
26+ branchConfigs,
27+ packages,
28+ rootDir,
29+ branch,
30+ tag,
31+ ghToken,
32+ releaseTogether = false ,
33+ } = options
2634
2735 const branchName = /** @type {string } */ ( branch ?? currentGitBranch ( ) )
2836 const isMainBranch = branchName === 'main'
@@ -227,16 +235,21 @@ export const publish = async (options) => {
227235 . filter ( Boolean )
228236
229237 /** Uses packages and changedFiles to determine which packages have changed */
230- const changedPackages = RELEASE_ALL
238+ const packagesWithChanges = packages . filter ( ( pkg ) => {
239+ const changed = changedFiles . some (
240+ ( file ) =>
241+ file . startsWith ( path . join ( pkg . packageDir , 'src' ) )
242+ || file . startsWith ( path . join ( pkg . packageDir , 'package.json' ) ) ,
243+ )
244+ return changed
245+ } )
246+
247+ // If RELEASE_ALL is set, release all packages
248+ // If releaseTogether is set, release all packages if any package has changed
249+ // Otherwise, only release packages that have changed
250+ const changedPackages = RELEASE_ALL || ( releaseTogether && packagesWithChanges . length > 0 )
231251 ? packages
232- : packages . filter ( ( pkg ) => {
233- const changed = changedFiles . some (
234- ( file ) =>
235- file . startsWith ( path . join ( pkg . packageDir , 'src' ) ) ||
236- file . startsWith ( path . join ( pkg . packageDir , 'package.json' ) ) ,
237- )
238- return changed
239- } )
252+ : packagesWithChanges
240253
241254 // If a package has a dependency that has been updated, we need to update the
242255 // package that depends on it as well.
0 commit comments