I am using semantic-release for our .Net Core solution. Semantic-release is used as part of the CI pipeline on GitLab repository.
This is my .releaserc.json
{
"plugins": [
"@semantic-release/commit-analyzer",
"@semantic-release/release-notes-generator",
["@semantic-release/changelog", {
"changelogFile": "CHANGELOG.md"
}],
["@semantic-release/exec", {
"publishCmd": "./publish.sh ${nextRelease.version}"
}],
"@semantic-release/gitlab"
],
"branches": [
"master",
{"name": "develop", "channel": "beta", "prerelease": "beta"},
{"name": "release", "channel": "RC", "prerelease": "RC"}
]
}
As you can see I am using simplified GitFlow.
I have a master branch, single release branch used for publishing release candidates and develop branch with the latest development code. There are also feature branches created from develop but they are not versioned.
The problem I am having is that once I merge the code from develop to release any commit done to develop branch will result in semantic-release not able to find the last tag create before the merge to release.
Let me try to explain what is happening.
Merge to develop, using squash, is created for a feature branch (which was created from develop) with commit message feat(Products): Add tag support this commit will result in new version v1.10.0-beta.11.
Next, I will merge the develop branch to release, this will result in 1.10.0-RC.1 version being created.
Next, I will do a new commit to develop branch which will result in semantic-release not being able to create a new version.
[11:09:42 AM] [semantic-release] › ✔ Completed step "verifyConditions" of plugin "@semantic-release/gitlab"
[11:09:42 AM] [semantic-release] › ℹ Found git tag v1.10.0-beta.10 associated with version 1.10.0-beta.10 on branch develop
[11:09:42 AM] [semantic-release] › ℹ Found 2 commits since last release
[11:09:42 AM] [semantic-release] › ℹ Start step "analyzeCommits" of plugin "@semantic-release/commit-analyzer"
[11:09:42 AM] [semantic-release] [@semantic-release/commit-analyzer] › ℹ Analyzing commit: feat(Products): One commit before Add tag support
[11:09:42 AM] [semantic-release] [@semantic-release/commit-analyzer] › ℹ The release type for the commit is minor
[11:09:42 AM] [semantic-release] [@semantic-release/commit-analyzer] › ℹ Analyzing commit: feat(Products): Add tag support
[11:09:42 AM] [semantic-release] [@semantic-release/commit-analyzer] › ℹ The release type for the commit is patch
[11:09:42 AM] [semantic-release] [@semantic-release/commit-analyzer] › ℹ Analysis of 2 commits complete: minor release
...
[11:09:42 AM] [semantic-release] › ℹ Start step "prepare" of plugin "@semantic-release/exec"
[11:09:42 AM] [semantic-release] › ✔ Completed step "prepare" of plugin "@semantic-release/exec"
[11:09:42 AM] [semantic-release] › ✖ An error occurred while running semantic-release: Error: Command failed with exit code 128: git tag v1.10.0-beta.11 a1ee6896485641d039f1816efcc0e30dce7139e8
fatal: tag 'v1.10.0-beta.11' already exists
...
All future commits to develop will fail. The only solution is to merge release to master branch.
If I merge develop to release again. This will happen:
[9:57:53 AM] [semantic-release] › ✔ Completed step "verifyConditions" of plugin "@semantic-release/gitlab"
[9:57:53 AM] [semantic-release] › ℹ Found git tag v1.10.0-beta.11 associated with version 1.10.0-beta.11 on branch release
[9:57:53 AM] [semantic-release] › ℹ Found 1 commits since last release
[9:57:53 AM] [semantic-release] › ℹ Start step "analyzeCommits" of plugin "@semantic-release/commit-analyzer"
[9:57:53 AM] [semantic-release] [@semantic-release/commit-analyzer] › ℹ Analyzing commit: fix(bug): Some bug fixed
[9:57:53 AM] [semantic-release] [@semantic-release/commit-analyzer] › ℹ The release type for the commit is patch
[9:57:53 AM] [semantic-release] [@semantic-release/commit-analyzer] › ℹ Analysis of 1 commits complete: patch release
[9:57:53 AM] [semantic-release] › ✔ Completed step "analyzeCommits" of plugin "@semantic-release/commit-analyzer"
...
[9:59:02 AM] [semantic-release] › ℹ Start step "publish" of plugin "@semantic-release/gitlab"
[9:59:02 AM] [semantic-release] [@semantic-release/gitlab] › ℹ Published GitLab release: v1.10.0-beta.12
[9:59:02 AM] [semantic-release] › ✔ Completed step "publish" of plugin "@semantic-release/gitlab"
[9:59:02 AM] [semantic-release] › ℹ Start step "success" of plugin "@semantic-release/exec"
[9:59:02 AM] [semantic-release] › ✔ Completed step "success" of plugin "@semantic-release/exec"
[9:59:02 AM] [semantic-release] › ✔ Published release 1.10.0-beta.12 on RC channel
It will publish beta release on RC channel.
To me, it looks like a configuration issue or maybe branching model issues. Any help would be appreciated!
Note: Initially I wanted to use the vanilla GitFlow branching model, but I ran in to even more issues with semantic-release, so I simplified it a bit.