From 5e174fc67cc2ca6686cf5f9f1a3c377eb0295a5c Mon Sep 17 00:00:00 2001 From: James Henry Date: Tue, 5 Dec 2023 18:07:18 +0400 Subject: [PATCH] fix(release): only early exit when no changelog changes if expecting commit (#20568) --- .../nx/src/command-line/release/changelog.ts | 25 +++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/packages/nx/src/command-line/release/changelog.ts b/packages/nx/src/command-line/release/changelog.ts index a8f338cdf2..4feadf44e9 100644 --- a/packages/nx/src/command-line/release/changelog.ts +++ b/packages/nx/src/command-line/release/changelog.ts @@ -334,8 +334,14 @@ async function applyChangesAndExit( let latestCommit = toSHA; const changes = tree.listChanges(); - // This could happen we using conventional commits, for example - if (!changes.length) { + + /** + * In the case where we are expecting changelog file updates, but there is nothing + * to flush from the tree, we exit early. This could happen we using conventional + * commits, for example. + */ + const changelogFilesEnabled = checkChangelogFilesEnabled(nxReleaseConfig); + if (changelogFilesEnabled && !changes.length) { output.warn({ title: `No changes detected for changelogs`, bodyLines: [ @@ -897,3 +903,18 @@ async function generateChangelogForProjects( printSummary(); } } + +function checkChangelogFilesEnabled(nxReleaseConfig: NxReleaseConfig): boolean { + if ( + nxReleaseConfig.changelog.workspaceChangelog && + nxReleaseConfig.changelog.workspaceChangelog.file + ) { + return true; + } + for (const releaseGroup of Object.values(nxReleaseConfig.groups)) { + if (releaseGroup.changelog && releaseGroup.changelog.file) { + return true; + } + } + return false; +}