nrwl / nx

Smart Monorepos · Fast CI
https://nx.dev
MIT License
23.17k stars 2.3k forks source link

release: too many authors in authors section #26949

Closed de-don closed 1 month ago

de-don commented 1 month ago

Current Behavior

I did small change in one of my libraries, and trying to publish it with nx release, and it generates changelog with too many authors, not relevant to my changes. Sometimes it includes wierd commit sha.

## 1.1.2 (2024-05-31)

### 🩹 Fixes

- example fix to check the build

### ❤️  Thank You

- Denis (Me)
- Other user 1
- Other user 2
- Other user 3
- Other user 4

Expected Behavior

Only authors of specific commits that described in changelog should be in authors

## 1.1.2 (2024-05-31)

### 🩹 Fixes

- example fix to check the build

### ❤️  Thank You

- Denis (Me)

GitHub Repo

No response

Steps to Reproduce

Don't know exactly how to reproduce, but I think the problem in changelog-renderer: when generating authors, it uses all changes but for changelog it uses relevantChanges

Nx Report

NX   Report complete - copy this into the issue template

Node   : 18.18.2
OS     : darwin-arm64
npm    : 9.8.1

nx                 : 19.4.3
@nx/js             : 19.4.3
@nx/jest           : 19.4.3
@nx/linter         : 19.4.3
@nx/eslint         : 19.4.3
@nx/workspace      : 19.4.3
@nx/angular        : 19.4.3
@nx/cypress        : 19.4.3
@nx/devkit         : 19.4.3
@nx/eslint-plugin  : 19.4.3
@nx/playwright     : 19.4.3
@nx/plugin         : 19.4.3
@nx/storybook      : 19.4.3
@nrwl/tao          : 19.4.3
@nx/web            : 19.4.3
@nx/webpack        : 19.4.3
nx-cloud           : 19.0.0
typescript         : 5.1.6
---------------------------------------
Registered Plugins:
@mono/executors
@nx/playwright/plugin
---------------------------------------
Community plugins:
@front/angular-builder : 16.2.0
@storybook/angular     : 7.6.20
nx-stylelint           : 17.1.5

Failure Logs

No response

Package Manager Version

9.8.1

Operating System

Additional Information

No response

tinesoft commented 1 month ago

Hi,

I was having the same issue, after debugging locally, I found out the culprit:

In the defaultChangelogRenderer Nx does filter relevant changes to consider for the project changelog (see at https://github.com/nrwl/nx/blob/b623104aac783e0591ef2381d697b87cdca655b6/packages/nx/release/changelog-renderer/index.ts#L200) but those filtered changes are not used when generating the authors section... (here :https://github.com/nrwl/nx/blob/b623104aac783e0591ef2381d697b87cdca655b6/packages/nx/release/changelog-renderer/index.ts#L282)

Here is a patch that solves the issue:

diff --git a/release/changelog-renderer/index.js b/release/changelog-renderer/index.js
index 5b2f41a880933f41856de81b11453c9b27efa733..f4bb0609a3c155fd0dcddfcb6393d888c06cd76c 100644
--- a/release/changelog-renderer/index.js
+++ b/release/changelog-renderer/index.js
@@ -25,10 +25,13 @@ const defaultChangelogRenderer = async ({ projectGraph, changes, releaseVersion,
             }
         }
     }
+
+    let relevantChanges = [];
     // workspace root level changelog
     if (project === null) {
+        relevantChanges = changes;
         // No changes for the workspace
-        if (changes.length === 0) {
+        if (relevantChanges.length === 0) {
             if (dependencyBumps?.length) {
                 applyAdditionalDependencyBumps({
                     markdownLines,
@@ -42,7 +45,7 @@ const defaultChangelogRenderer = async ({ projectGraph, changes, releaseVersion,
             }
             return markdownLines.join('\n').trim();
         }
-        const typeGroups = groupBy(changes, 'type');
+        const typeGroups = groupBy(relevantChanges, 'type');
         markdownLines.push('', createVersionTitle(releaseVersion, changelogRenderOptions), '');
         for (const type of Object.keys(changeTypes)) {
             const group = typeGroups[type];
@@ -75,7 +78,7 @@ const defaultChangelogRenderer = async ({ projectGraph, changes, releaseVersion,
     }
     else {
         // project level changelog
-        const relevantChanges = changes.filter((c) => c.affectedProjects &&
+         relevantChanges = changes.filter((c) => c.affectedProjects &&
             (c.affectedProjects === '*' || c.affectedProjects.includes(project)));
         // Generating for a named project, but that project has no relevant changes in the current set of commits, exit early
         if (relevantChanges.length === 0) {
@@ -128,7 +131,7 @@ const defaultChangelogRenderer = async ({ projectGraph, changes, releaseVersion,
     }
     if (changelogRenderOptions.authors) {
         const _authors = new Map();
-        for (const change of changes) {
+        for (const change of relevantChanges) {
             if (!change.author) {
                 continue;
             }

I will try to push a PR, once I manage to have my devcontainer setup working again

JamesHenry commented 1 month ago

Thanks folks, this will be addressed by https://github.com/nrwl/nx/pull/27181

github-actions[bot] commented 1 week ago

This issue has been closed for more than 30 days. If this issue is still occuring, please open a new issue with more recent context.