@@ -45,7 +45,15 @@ function currentGitBranch() {
45
45
* @returns {Promise<void> }
46
46
*/
47
47
export const publish = async ( options ) => {
48
- const { branchConfigs, packages, rootDir, branch, tag, ghToken } = options
48
+ const {
49
+ branchConfigs,
50
+ packages,
51
+ rootDir,
52
+ branch,
53
+ tag,
54
+ ghToken,
55
+ releaseTogether = false ,
56
+ } = options
49
57
50
58
const branchName = /** @type {string } */ ( branch ?? currentGitBranch ( ) )
51
59
const isMainBranch = branchName === 'main'
@@ -250,16 +258,22 @@ export const publish = async (options) => {
250
258
. filter ( Boolean )
251
259
252
260
/** Uses packages and changedFiles to determine which packages have changed */
253
- const changedPackages = RELEASE_ALL
254
- ? packages
255
- : packages . filter ( ( pkg ) => {
256
- const changed = changedFiles . some (
257
- ( file ) =>
258
- file . startsWith ( path . join ( pkg . packageDir , 'src' ) ) ||
259
- file . startsWith ( path . join ( pkg . packageDir , 'package.json' ) ) ,
260
- )
261
- return changed
262
- } )
261
+ const packagesWithChanges = packages . filter ( ( pkg ) => {
262
+ const changed = changedFiles . some (
263
+ ( file ) =>
264
+ file . startsWith ( path . join ( pkg . packageDir , 'src' ) ) ||
265
+ file . startsWith ( path . join ( pkg . packageDir , 'package.json' ) ) ,
266
+ )
267
+ return changed
268
+ } )
269
+
270
+ // If RELEASE_ALL is set, release all packages
271
+ // If releaseTogether is set, release all packages if any package has changed
272
+ // Otherwise, only release packages that have changed
273
+ const changedPackages =
274
+ RELEASE_ALL || ( releaseTogether && packagesWithChanges . length > 0 )
275
+ ? packages
276
+ : packagesWithChanges
263
277
264
278
// If a package has a dependency that has been updated, we need to update the
265
279
// package that depends on it as well.
0 commit comments