fix(release): only early exit when no changelog changes if expecting commit (#20568)

This commit is contained in:
James Henry 2023-12-05 18:07:18 +04:00 committed by GitHub
parent eb481513e7
commit 5e174fc67c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -334,8 +334,14 @@ async function applyChangesAndExit(
let latestCommit = toSHA; let latestCommit = toSHA;
const changes = tree.listChanges(); 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({ output.warn({
title: `No changes detected for changelogs`, title: `No changes detected for changelogs`,
bodyLines: [ bodyLines: [
@ -897,3 +903,18 @@ async function generateChangelogForProjects(
printSummary(); 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;
}