rushstack icon indicating copy to clipboard operation
rushstack copied to clipboard

[rush] rush publish --regenerate-changelogs does not regenerate CHANGELOG.md

Open kkazala opened this issue 3 years ago • 4 comments

Summary

  • rush version --bump, correctly generates CHANGELOG.json and CHANGELOG.md files for all the changed projects defined in rush.json
  • After manually updating CHANGELOG.json file, I'm executing rush publish --regenerate-changelogs, expecting the corresponsing CHANGELOG.md file to be updated accordingly
  • The following message is printed to the console:
Rush Multi-Project Build Tool 5.66.2 - https://rushjs.io
Node.js version is 14.19.1 (LTS)

Starting "rush publish"

Checking Git policy for this repository.

Validating package manager shrinkwrap file.

Regenerating changelogs
Found: C:\[...]\Libraries\projectA\CHANGELOG.md
Found: C:\[...]\Libraries\projectB\CHANGELOG.md
Found: C:\[...]\Apps\projectC\CHANGELOG.md
Found: C:\[...]\Apps\projectD\CHANGELOG.md

CHANGELOG.md is NOT updated

What were you trying to accomplish? After manually updating CHANGELOG.json, I want the CHANGELOG.md to reflect these changes What action did you perform that ran into trouble? rush publish --regenerate-changelogs What went wrong? CHANGELOG.md is NOT updated

Repro steps

  • Use a monorepo with all the managed projects using individualVersion versionPolicy.
  • According to Publishing process when version policies are used, the process consists of two steps:
    • rush version --bump: which generates CHANGELOG.json and CHANGELOG.md, and
    • rush publish --include-all

I was hoping to update the changelogs before publishing the packages, which would result in the following steps:

  • rush version --bump
  • manually update CHANGELOG.json
  • rush publish --regenerate-changelogs
  • rush publish --include-all

Expected result: CHANGELOG.md is updated according to my changes in CHANGELOG.json, e.g. description of the last version is updated

Actual result: ChangelogGenerator.regenerateChangelogs correctly finds projects managed by rush and the CHANGELOG.md files but doesn't update them

Details

  public static regenerateChangelogs(
    allProjects: Map<string, RushConfigurationProject>,
    rushConfiguration: RushConfiguration
  ): void {
    allProjects.forEach((project) => {
      const markdownPath: string = path.resolve(project.projectFolder, CHANGELOG_MD);
      const markdownJSONPath: string = path.resolve(project.projectFolder, CHANGELOG_JSON);

      if (FileSystem.exists(markdownPath)) {
        // ---------THIS WORKS-------
        console.log('Found: ' + markdownPath);
        if (!FileSystem.exists(markdownJSONPath)) {
          throw new Error('A CHANGELOG.md without json: ' + markdownPath);
        }
        // ---------THIS WORKS-------

        // ---------THIS DOES NOT WORK???-------
        const changelog: IChangelog = ChangelogGenerator._getChangelog(
          project.packageName,
          project.projectFolder
        );
        const isLockstepped: boolean = !!project.versionPolicy && project.versionPolicy.isLockstepped;

        FileSystem.writeFile(
          path.join(project.projectFolder, CHANGELOG_MD),
          ChangelogGenerator._translateToMarkdown(changelog, rushConfiguration, isLockstepped)
        );
        // ---------THIS DOES NOT WORK???-------
      }
    });
  }

Standard questions

Please answer these questions to help us investigate your issue more quickly:

Question Answer
@microsoft/rush globally installed version? 5.66.2
rushVersion from rush.json? 5.66.2
useWorkspaces from rush.json? true
Operating system? Windows
Would you consider contributing a PR? No. Sorry, don't think I'm able to
Node.js version (node -v)? v14.19.1

kkazala avatar Apr 22 '22 13:04 kkazala

CHANGELOG.json and CHANGELOG.md are generated together from the same data (the changefiles that rush change drops in common/changes). CHANGELOG.json doesn't drive CHANGELOG.md. This change would be a somewhat fundamental change to how changelogs are generated. We have been talking about redesigning the way changelogs and publishing work, so this is a useful point of feedback, though.

It may be possible to write a small tool that uses rush-lib to generate CHANGELOG.md from the data that ends up in CHANGELOG.json. Would you be able to explore that option to support your scenario?

iclanton avatar Apr 25 '22 19:04 iclanton

Hi Ian Certainly. I should be able to start next week :)


From: Ian Clanton-Thuon @.> Sent: Monday, April 25, 2022 9:24:33 PM To: microsoft/rushstack @.> Cc: Kinga @.>; Author @.> Subject: Re: [microsoft/rushstack] [rush] rush publish --regenerate-changelogs does not regenerate CHANGELOG.md (Issue #3365)

CHANGELOG.json and CHANGELOG.md are generated together from the same data (the changefiles that rush change drops in common/changes). CHANGELOG.json doesn't drive CHANGELOG.md. This change would be a somewhat fundamental change to how changelogs are generated. We have been talking about redesigning the way changelogs and publishing work, so this is a useful point of feedback, though.

It may be possible to write a small tool that uses rush-lib to generate CHANGELOG.md from the data that ends up in CHANGELOG.json. Would you be able to explore that option to support your scenario?

— Reply to this email directly, view it on GitHubhttps://github.com/microsoft/rushstack/issues/3365#issuecomment-1108951363, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AFLD3H66WJZYAXSDIPDYZRLVG3WPDANCNFSM5UCMSMWQ. You are receiving this because you authored the thread.Message ID: @.***>

kkazala avatar Apr 26 '22 07:04 kkazala

OK thank you


From: Kinga @.> Sent: Monday, April 25, 2022 11:49 PM To: microsoft/rushstack @.> Cc: Subscribed @.***> Subject: Re: [microsoft/rushstack] [rush] rush publish --regenerate-changelogs does not regenerate CHANGELOG.md (Issue #3365)

Hi Ian Certainly. I should be able to start next week :)


From: Ian Clanton-Thuon @.> Sent: Monday, April 25, 2022 9:24:33 PM To: microsoft/rushstack @.> Cc: Kinga @.>; Author @.> Subject: Re: [microsoft/rushstack] [rush] rush publish --regenerate-changelogs does not regenerate CHANGELOG.md (Issue #3365)

CHANGELOG.json and CHANGELOG.md are generated together from the same data (the changefiles that rush change drops in common/changes). CHANGELOG.json doesn't drive CHANGELOG.md. This change would be a somewhat fundamental change to how changelogs are generated. We have been talking about redesigning the way changelogs and publishing work, so this is a useful point of feedback, though.

It may be possible to write a small tool that uses rush-lib to generate CHANGELOG.md from the data that ends up in CHANGELOG.json. Would you be able to explore that option to support your scenario?

— Reply to this email directly, view it on GitHubhttps://github.com/microsoft/rushstack/issues/3365#issuecomment-1108951363, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AFLD3H66WJZYAXSDIPDYZRLVG3WPDANCNFSM5UCMSMWQ. You are receiving this because you authored the thread.Message ID: @.***>

— Reply to this email directly, view it on GitHubhttps://github.com/microsoft/rushstack/issues/3365#issuecomment-1109464171, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AXYWCLL4BY54NXVE6L6NMOLVG6NYXANCNFSM5UCMSMWQ. You are receiving this because you are subscribed to this thread.Message ID: @.***>

calbearox avatar Apr 26 '22 08:04 calbearox

@calbearox I finally :see_no_evil: found time to look into this.

"CHANGELOG.json doesn't drive CHANGELOG.md." It actually does. This is why, on top of the CHANGELOG.md, there's a warning: "This log was last generated on ... and should not be manually modified."

If I edit CHANGELOG.json and run rush publish --regenerate-changelogs, any manual edits of CHANGELOG.md are lost and the CHANGELOG.md is generated from the scratch based on the manually updated CHANGELOG.json.

One exception being the initial version that always, no matter what, gets "Initial release" description. I think this is what gave me impression that the command doesn't work correctly.

Do you think it might be useful to publish ChangelogGenerator.regenerateChangelogs as a method of ChangeManager class? I'm currently using a custom rush command that, among other things, executes utils.executeCommand(rush --quiet publish --regenerate-changelogs);. I think it would be nicer to use rush API, but I can also live without it =)

kkazala avatar Jun 19 '22 15:06 kkazala

Closing - it looks like this feature is working as intended, i.e., you can regenerate the markdown files from the json files using the command: rush publish --regenerate-changelogs.

(This is probably the simplest way to accomplish this via custom scripts and CI workflows, but any PRs to make it even easier are always welcome!)

elliot-nelson avatar Dec 01 '22 14:12 elliot-nelson