commit-analyzer icon indicating copy to clipboard operation
commit-analyzer copied to clipboard

Adding ReleaseRules types list is working fine with release versioning but Changelog commits are empty.

Open isabr85 opened this issue 3 years ago • 3 comments

I've added to @semantic-release/commit-analyzer plugin a list of types under releaseRules:

module.exports = {
    branches: [
        '+([0-9])?(.{+([0-9]),x}).x',
        'main', 
        'dev',
	'master'
    ],
    plugins: [
		["@semantic-release/commit-analyzer", {
		  preset: "angular",
		  releaseRules: [
			{type: "docs", release: "patch"},
			{type: "refactor", release: "patch"},
			{type: "ci", release: "patch"},
			{type: "style", release: "patch"},
			{type: "test", release: "patch"},
			{type: "chore", release: "patch"}
		  ]
		}],
        ['@semantic-release/release-notes-generator', {
            writerOpts: {
                finalizeContext: function (context) {
                    return {
                        ...context,
                        repository: 'myRepository',
                        owner: 'ownerName',
                        repoUrl: 'https://dev.azure.com',
                        commit: '_git/projectName/commit',
                        linkCompare: false
                    };
                }
            },
            host: 'https://dev.azure.com',
            issue: '_workitems/edit'
        }],
        '@semantic-release/changelog'
    ],
    prepare: [
        ["@semantic-release/exec", {
            "prepareCmd": 'echo ##vso[task.setvariable variable=nextRelease]${nextRelease.version}'
        }],
        '@semantic-release/changelog',
        [ 
            '@semantic-release/git',
            { 
                message: 'ci(release): <%= nextRelease.version %> \n\n<%= nextRelease.notes %>'
            }
        ] 
    ]
}; 

It seems to be fine, when I make a commit of one of the types displayed in the list I can clearly see that release version is being increasing according to my definition. But then I am looking at CHANGELOG.md file and it seems that commits are not being written and it left blanked.

image

Any idea what can cause this issue? I tried to search for a solution for this scenario few days and I feel I don't have any way to solve it by my own.

Can you tell me what is wrong with my script?

isabr85 avatar May 27 '21 09:05 isabr85

So the commit analyzer has nothing to do with writing the changelog. It just tells semantic-release whether there should be a release or not.

@semantic-release/release-notes-generator determines which commit types show up in the changelog and IIRC default it's just feat and fix types.

I'll share part of my config show you hopefully you'll get the idea:


[
      "@semantic-release/release-notes-generator",
      {
        "preset": "conventionalcommits",
        "presetConfig": {
          "types": [
            {
              "type": "feat",
              "section": "New Feature(s) 🚀"
            },
            {
              "type": "fix",
              "section": "Bug Fix(es) 🐛️"
            },
            {
              "type": "docs",
              "section": "Documentation Changes 📝"
            },
            {
              "type": "refactor",
              "section": "Code Refactoring 💅"
            },
            {
              "type": "test",
              "section": "Tests 📡️"
            },
            {
              "type": "perf",
              "section": "Performance Improvement(s) 🚄️"
            },
            {
              "type": "build",
              "section": "Build system 🛠️"
            }
          ]
        }
      }
    ],

Let me know if this helps 😄

tmeijn avatar Jul 17 '21 22:07 tmeijn

@tmeijn this worked and helped understand what was going on with the empty changelog, but I notice that for the breaking changes it is using a section called ⚠ BREAKING CHANGES, I tried to change this by using the same config you provided but adding another config at the start (just added it for feat! to see if it works but not so far):

[
      "@semantic-release/release-notes-generator",
      {
        "preset": "conventionalcommits",
        "presetConfig": {
          "types": [
            {
              "breaking": true,
              "type": "feat!",
              "section": "BREAKING"
            },
            {
              "type": "feat",
              "section": "New Feature(s) 🚀"
            },
            {
              "type": "fix",
              "section": "Bug Fix(es) 🐛️"
            },
            {
              "type": "docs",
              "section": "Documentation Changes 📝"
            },
            {
              "type": "refactor",
              "section": "Code Refactor 💅"
            },
            {
              "type": "test",
              "section": "Tests 📡️"
            },
            {
              "type": "perf",
              "section": "Performance Improvement(s) 🚄️"
            },
            {
              "type": "build",
              "section": "Build system 🛠️"
            }
          ]
        }
      }
    ]

In other words I could not figure out how to change the section name for the breaking changes, appreciate any help/guidance/guesses

arkadioz avatar Jan 02 '24 01:01 arkadioz

Hey @arkadioz, sorry for the late response, but that section is hard coded in the conventionalcommits package. I started an effort a long time ago (https://github.com/conventional-changelog/conventional-changelog/pull/981/files) to make it configurable, but abandoned the PR it will likely not get to it soon/at all.

tmeijn avatar Jan 15 '24 11:01 tmeijn