Skip to content

Commit 8a24b55

Browse files
author
JP Rosevear
committed
feat: Release together flag
1 parent 22ac3f8 commit 8a24b55

File tree

2 files changed

+27
-11
lines changed

2 files changed

+27
-11
lines changed

packages/publish-config/src/index.d.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ export type Options = {
3131
tag?: string
3232
/** The GitHub token used to search for user metadata and make a GitHub release. */
3333
ghToken?: string
34+
/** If releasing any package, release all packages together. Defaults to false */
35+
releaseTogether?: boolean
3436
}
3537

3638
/** https://tanstack.com/config/latest/docs/publish */

packages/publish-config/src/index.js

Lines changed: 25 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,15 @@ function currentGitBranch() {
4545
* @returns {Promise<void>}
4646
*/
4747
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
4957

5058
const branchName = /** @type {string} */ (branch ?? currentGitBranch())
5159
const isMainBranch = branchName === 'main'
@@ -250,16 +258,22 @@ export const publish = async (options) => {
250258
.filter(Boolean)
251259

252260
/** 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
263277

264278
// If a package has a dependency that has been updated, we need to update the
265279
// package that depends on it as well.

0 commit comments

Comments
 (0)