Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
isabr85 opened this issue May 27, 2021 · 3 comments

Comments

@isabr85
Copy link

isabr85 commented May 27, 2021

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?

@tmeijn
Copy link

tmeijn commented Jul 17, 2021

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 😄

@arkadioz
Copy link

arkadioz commented Jan 2, 2024

@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

@tmeijn
Copy link

tmeijn commented Jan 15, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants