Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions packages/publish-config/src/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ export type Options = {
tag?: string
/** The GitHub token used to search for user metadata and make a GitHub release. */
ghToken?: string
/** If releasing any package, release all packages together. Defaults to false */
releaseTogether?: boolean
}

/** https://tanstack.com/config/latest/docs/publish */
Expand Down
36 changes: 25 additions & 11 deletions packages/publish-config/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,15 @@ function currentGitBranch() {
* @returns {Promise<void>}
*/
export const publish = async (options) => {
const { branchConfigs, packages, rootDir, branch, tag, ghToken } = options
const {
branchConfigs,
packages,
rootDir,
branch,
tag,
ghToken,
releaseTogether = false,
} = options

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

/** Uses packages and changedFiles to determine which packages have changed */
const changedPackages = RELEASE_ALL
? packages
: packages.filter((pkg) => {
const changed = changedFiles.some(
(file) =>
file.startsWith(path.join(pkg.packageDir, 'src')) ||
file.startsWith(path.join(pkg.packageDir, 'package.json')),
)
return changed
})
const packagesWithChanges = packages.filter((pkg) => {
const changed = changedFiles.some(
(file) =>
file.startsWith(path.join(pkg.packageDir, 'src')) ||
file.startsWith(path.join(pkg.packageDir, 'package.json')),
)
return changed
})

// If RELEASE_ALL is set, release all packages
// If releaseTogether is set, release all packages if any package has changed
// Otherwise, only release packages that have changed
const changedPackages =
RELEASE_ALL || (releaseTogether && packagesWithChanges.length > 0)
? packages
: packagesWithChanges

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