romap0 / semantic-release-unsquash

Wrapper for @semantic-release/commit-analyzer which works with squashed MRs
11 stars 3 forks source link

bug: Duplicated title in changelog are generated #2

Closed Elio-FairlyMade closed 10 months ago

Elio-FairlyMade commented 10 months ago

Hello, first, thanks for your work !

I was trying to use your lib to parse my squashed commits. It seems to work well for the analyze but it seems to create 2 entries in the changelog file.

Here is an example of the duplicated line in the changelog (The line starts with ## [1.3.0]) image

Here is my release.config.js file :

/* eslint-disable no-template-curly-in-string,no-unused-vars */
let envFile = 'project-version.env';

if (process.env.GITHUB_ENV) {
  envFile = process.env.GITHUB_ENV;
}

module.exports = {
  repositoryUrl: 'https://github.com/FairlyMade/poc-tools-semantic-release.git',
  branches: ['release/*', 'hotfix/*', 'dev', 'main'], // Branch to trigger releases (change as needed)
  plugins: [
    ["semantic-release-unsquash", {
      "commitAnalyzerConfig": {
        "preset": "angular",
        "releaseRules": [
          { type: '^build', release: 'patch' },
          { type: '^chore', release: 'patch' },
          { type: '^ci', release: 'patch' },
          { type: '^docs', release: false },
          { type: '^feat', release: 'minor' },
          { type: '^fix', release: 'patch' },
          { type: '^perf', release: 'patch' },
          { type: '^refactor', release: 'patch' },
          { type: '^secu', release: 'patch' },
          { type: '^style', release: 'patch' },
          { type: '^test', release: 'patch' },
        ],
        "parserOpts": {
          "noteKeywords": ["BREAKING CHANGE", "BREAKING CHANGES", "BREAKING"]
        }
      },
      "notesGeneratorConfig": {
        preset: 'conventionalcommits',
        presetConfig: {
          types: [
            { type: 'build', hidden: true },
            { type: 'chore', hidden: true },
            { type: 'ci', hidden: true },
            { type: 'docs', section: '๐Ÿ“ Documentation', hidden: false },
            { type: 'feat', section: '๐Ÿš€ Features', hidden: false },
            { type: 'fix', section: '๐Ÿ› Bug Fixes', hidden: false },
            { type: 'perf', section: '๐Ÿƒ Performance', hidden: false },
            { type: 'refactor', section: '๐Ÿ  Refactor', hidden: false },
            { type: 'secu', section: '๐Ÿ”’ Security', hidden: false },
            { type: 'style', section: '๐Ÿชž Styling', hidden: false },
            { type: 'test', section: '๐Ÿงช Testing', hidden: false },
          ],
        },
      },
    }],
    [
      '@semantic-release/changelog',
      {
        changelogFile: 'CHANGELOG.md',
        changelogTitle:
          '# Changelog\n\nAll notable changes to this project will be documented in this file.',
      },
    ],
    [
      '@semantic-release/commit-analyzer',
      {
        preset: 'angular',
        releaseRules: [
          // build|chore|ci|docs|feat|fix|perf|refactor|secu|style|test
          // major|minor|patch|false
          { type: '^build', release: 'patch' },
          { type: '^chore', release: 'patch' },
          { type: '^ci', release: 'patch' },
          { type: '^docs', release: false },
          { type: '^feat', release: 'minor' },
          { type: '^fix', release: 'patch' },
          { type: '^perf', release: 'patch' },
          { type: '^refactor', release: 'patch' },
          { type: '^secu', release: 'patch' },
          { type: '^style', release: 'patch' },
          { type: '^test', release: 'patch' },
        ],
        parserOpts: {
          noteKeywords: ['BREAKING CHANGE', 'BREAKING CHANGES'],
        },
      },
    ],
    [
      '@semantic-release/release-notes-generator',
      {
        preset: 'conventionalcommits',
        presetConfig: {
          types: [
            { type: 'build', hidden: true },
            { type: 'chore', hidden: true },
            { type: 'ci', hidden: true },
            { type: 'docs', section: '๐Ÿ“ Documentation', hidden: false },
            { type: 'feat', section: '๐Ÿš€ Features', hidden: false },
            { type: 'fix', section: '๐Ÿ› Bug Fixes', hidden: false },
            { type: 'perf', section: '๐Ÿƒ Performance', hidden: false },
            { type: 'refactor', section: '๐Ÿ  Refactor', hidden: false },
            { type: 'secu', section: '๐Ÿ”’ Security', hidden: false },
            { type: 'style', section: '๐Ÿชž Styling', hidden: false },
            { type: 'test', section: '๐Ÿงช Testing', hidden: false },
          ],
        },
      },
    ],
    [
      '@semantic-release/npm',
      {
        // Specify that you only want to bump the version without publishing
        npmPublish: false,
      },
    ],
    '@semantic-release/git', // Commit version and changelog files to the repository
    [
      '@semantic-release/github',
      {
        addReleases: 'bottom',
        failTitle: false
      },
    ],
    [
      '@semantic-release/exec',
      {
        publishCmd: `echo "GIT_VERSION=\${nextRelease.version}" >> ${envFile}`,
      },
    ],
  ],
};

Do you have any clues of what's going on ?

Thanks a lot :)

Elio-FairlyMade commented 10 months ago

I'm closing this issue because my config was the issue, I didn't understood that I needed only one config for @semantic-release/commit-analyzer and @semantic-release/release-notes-generator :)

Removing config for both of them and configuring them only in semantic-release-unsquash works as intended :)

Thanks again for your lib ๐Ÿฅ‡