javascriptsemantic-releaserelease-notes

Semantic Release - Add more sections to auto-generated release notes


I've just finished setting up semantic-release for my node project and made the first release with it:

Release notes

It seems that only commits with type fix or feat are added to the release notes... I want to be able to show improvement type as well.

Is there a way to configure/add it? Thanks!


Solution

  • The changelog text is generated by conventional-changelog-angular by default and it's over there that the type of commit to include in the change log are determined.

    See https://github.com/conventional-changelog/conventional-changelog/blob/master/packages/conventional-changelog-angular/writer-opts.js#L45

    If you want to include other type of commit in the changelog you can create your own preset (based on conventional-changelog-angular) that would include all the commits type.

    Alternatively you can use the conventional-changelog-conventionalcommits preset which support the types option to define new types and if they should be included in the release note.

    You semantic-release config would be:

    {
      "plugins": [
        ["@semantic-release/commit-analyzer", {
          "preset": "conventionalcommits",
          "releaseRules": [
            {"type": "improvement", "release": "minor"}
          ]
        }],
        ["@semantic-release/release-notes-generator", {
          "preset": "conventionalcommits",
          "presetConfig": {
            "types": [
              {"type": "feat", "section": "Features"},
              {"type": "fix", "section": "Bug Fixes"},
              {"type": "perf", "section": "Performance Improvements"},
              {"type": "revert", "section": "Reverts"},
              {"type": "docs", "section": "Documentation", "hidden": true},
              {"type": "style", "section": "Styles", "hidden": true},
              {"type": "chore", "section": "Miscellaneous Chores", "hidden": true},
              {"type": "refactor", "section": "Code Refactoring", "hidden": true},
              {"type": "test", "section": "Tests", "hidden": true},
              {"type": "build", "section": "Build System", "hidden": true},
              {"type": "ci", "section": "Continuous Integration", "hidden": true},
              {"type": "improvement", "section": "Improvement", "hidden": false}
            ]
          }
        }]
      ]
    }
    

    I added the releaseRules config for @semantic-release/commit-analyzer as I assume you want to create a minor releases for improvement commits.