semantic-release / release-notes-generator

:clipboard: semantic-release plugin to generate changelog content with conventional-changelog
MIT License
298 stars 47 forks source link

Question: Merging pre-release branches & generated changelog #606

Open fjakop opened 4 months ago

fjakop commented 4 months ago

We're using semantic-release in our projects with many collaborators. When we develop a new feature we're creating a pre-release branch which publishes to a dist-tag named according to this branch name, so other developers can use it.

Let's say we develop feature-foo, we get pre-releases with dist-tag @feature-foo and tags x.y.z-feature-foo.1 and so on (x.y.z is the previous release version on that branch).

Since we have activated semantic-release/changelog in our .releaserc.json (see below), every pre-release will get a changelog entry according to its commit comments and a release header like this:

CHANGELOG.md

### Features

*  My commit comment 2 ([d762374](link omitted))

# [x.y.z-feature-foo.2](link omitted) (2024-2-14)

### Features

*  My commit comment 1 ([4e6731c](link omitted))

# [x.y.z-feature-foo.1](link omitted) (2024-2-14)

Now when the feature is finished, we merge the feature branch by Gitlab Mmerge request to the main branch. This causes the changelog file and every pre-release entry to be merged into the main branch changelog too, which clutters the changelog and is clearly not desired.

Now the questions:

Kind regards Frank

.releaserc.json

{
  "branches": [
    {"name": "feature-([0-9A-Za-z-]+)", "prerelease": true},
  ],
  "plugins": [
    "@semantic-release/commit-analyzer",
    "@semantic-release/release-notes-generator",
    "@semantic-release/changelog",
    "@semantic-release/gitlab",
    "@semantic-release/npm",
    [
      "@semantic-release/git",
      {
        "assets": ["package.json", "CHANGELOG.md"],
        "message": "chore(release): ${nextRelease.version} [skip ci]\n\n${nextRelease.notes}"
      }
    ]
  ]
}