Branch is setup to *not* be a prerelease, yet the release is flagged as 'pre-release'.
{
"branches": [
{
"name": "main",
"prerelease": false
},
{
"name": "development",
"prerelease": true
},
{
"name": "staging",
"prerelease": false
}
],
"plugins": [
"@semantic-release/commit-analyzer",
"@semantic-release/release-notes-generator",
"@semantic-release/github"
]
}
This config does not throw an error, but behaves inconsistent. Pushing to staging does not create a release, but a pre-release.
I see the same behavior, @boxcee were you able to find a workaround?
@aslafy-z, no, unfortunately, I didn't.
Same here. 😢
Any fix?
It may be due to this check: https://github.com/semantic-release/github/blob/master/lib/is-prerelease.js#L1. It tags as pre-release any branch marked as pre-release, or any branch marked as release and not tagged as main.
As per https://github.com/semantic-release/semantic-release/blob/971a5e0d16f1a32e117e9ce382a1618c8256d0d9/lib/branches/normalize.js#L87, it looks like there can be only one main tagged branch, thus, only one branch not beeing used as pre-release (in the case of the GitHub plugin).
I was not able to find references with multiple main branches, see https://github.com/semantic-release/semantic-release/blob/971a5e0d16f1a32e117e9ce382a1618c8256d0d9/test/branches/normalize.test.js#L150.
This issue was introduced with https://github.com/semantic-release/github/pull/235.
Possible workaround
In my case I'm defining two branches objects:
branches: [
'release/+([0-9])?(.{+([0-9]),x}).x',
'master',
],
Moving the master branch first should prevent pre-releases from being created for this branch.
Agree with @aslafy-z, perhaps an error can be thrown instead that explains that only one release branch is allowed in the configuration?
My workaround prevent me from backporting changes to my releases branches. I got messages like
SemanticReleaseError: The release `1.42.2` on branch `release/1.42.x` cannot be published as it is out of range.
at module.exports (/app/node_modules/semantic-release/lib/get-error.js:6:10)
at run (/app/node_modules/semantic-release/index.js:173:11)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at async module.exports (/app/node_modules/semantic-release/index.js:260:22)
at async module.exports (/app/node_modules/semantic-release/cli.js:55:5) {
code: 'EINVALIDNEXTVERSION',
details: 'Based on the releases published on other branches, only versions within the range `>=1.43.0` can be published from branch `release/1.42.x`.\n' +
'\n' +
'The following commits are responsible for the invalid release:\n' +
'- backport: feat: add backport mode to semantic release (#2646) (5c11ffef)\n' +
'- backport: feat(onecaas): Force change vmss (#2639) (61fa50a8)\n' +
'- backport: fix(onecaas): upgrade volume snapshot crd for v1.24 (#2636) (4d22fd7a)\n' +
'- backport: deps(onecaas): upgrade azure csi (#2623) (c1a4814f)\n' +
'- backport: feat: alertmanager inhibit rules (#2627) (35b6cd68)\n' +
'- backport: fix(onecaas): increase thanos memory (#2619) (7b14892d)\n' +
'\n' +
'Those commits should be moved to a valid branch with [git merge](https://git-scm.com/docs/git-merge) or [git cherry-pick](https://git-scm.com/docs/git-cherry-pick) and removed
from branch `release/1.42.x` with [git revert](https://git-scm.com/docs/git-revert) or [git reset](https://git-scm.com/docs/git-reset).\n' +
'\n' +
'A valid branch could be `master` or `release/1.42.x`.\n' +
'\n' +
'See the [workflow configuration documentation](https://github.com/semantic-release/semantic-release/blob/master/docs/usage/workflow-configuration.md) for more details.',
I had to reorder the branches like
branches: [
'release/+([0-9])?(.{+([0-9]),x}).x',
'master',
],