From 7c6a1174148736a9a5c3792796ba6324096accfa Mon Sep 17 00:00:00 2001 From: JP Rosevear Date: Tue, 12 Mar 2024 09:01:23 -0400 Subject: [PATCH] feat: release all flag --- src/publish/index.js | 20 ++++++++++++++++---- src/publish/types.d.ts | 2 ++ 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/src/publish/index.js b/src/publish/index.js index cb22b4b..969f1b9 100644 --- a/src/publish/index.js +++ b/src/publish/index.js @@ -25,7 +25,15 @@ import { * @returns {Promise} */ export const publish = async (options) => { - const { branchConfigs, packages, rootDir, branch, tag, ghToken } = options + const { + branchConfigs, + packages, + rootDir, + branch, + tag, + ghToken, + releaseAll = false, + } = options const branchName = /** @type {string} */ (branch ?? currentGitBranch()) const isMainBranch = branchName === 'main' @@ -65,9 +73,13 @@ export const publish = async (options) => { let range = `${latestTag}..HEAD` // let range = ``; - // If RELEASE_ALL is set via a commit subject or body, all packages will be - // released regardless if they have changed files matching the package srcDir. - let RELEASE_ALL = false + // All packages will be released if any of the following conditions are met: + // - RELEASE_ALL is set via a commit subject or body + // - A tag is explicitly set + // - The config option releaseAll is set to true + // + // Otherwise, only packages with changed files matching the package srcDir will be released. + let RELEASE_ALL = releaseAll if (!latestTag || tag) { if (tag) { diff --git a/src/publish/types.d.ts b/src/publish/types.d.ts index c241761..5c346cb 100644 --- a/src/publish/types.d.ts +++ b/src/publish/types.d.ts @@ -56,4 +56,6 @@ export type RunOptions = { tag?: string // The GitHub token used to search for user metadata and make a GitHub release. ghToken?: string + /** Release all packages. Defaults to false but can be overridden with RELEASE_ALL in a commit message */ + releaseAll?: boolean }