Bug Description
When on a prerelease branch, conventional commit messages (e.g., fix:, feat:) cause the version number to bump instead of incrementing the prerelease (rc) number.
Expected Behavior
Given:
- Previous tag:
v1.1.1-rc.0
- New commit with message:
fix: some bug fix
- Branch is a prerelease branch
Expected new tag: v1.1.1-rc.1 (rc increment)
Actual Behavior
Actual new tag: v1.1.2-rc.0 (patch bump + rc reset)
Root Cause
In src/action.ts, when a conventional commit bump is detected on a prerelease branch:
const releaseType: ReleaseType = isPrerelease
? `pre${bump}` // bump="patch" → "prepatch"
: bump || defaultBump;
semver.inc("1.1.1-rc.0", "prepatch", "rc") returns 1.1.2-rc.0 — it bumps the patch version and resets the rc counter.
The correct behavior when the previous tag is already a prerelease at the same or higher bump level should be to use prerelease as the release type:
semver.inc("1.1.1-rc.0", "prerelease", "rc") returns 1.1.1-rc.1
The version bump from conventional commits should only be applied on the first prerelease (e.g., going from v1.1.0 release to v1.1.1-rc.0), not on subsequent prereleases where the bump has already been applied.
Configuration
uses: mathieudutour/github-tag-action@v6.2
with:
github_token: ${{ secrets.TOKEN }}
default_bump: patch
default_prerelease_bump: prerelease
append_to_pre_release_tag: rc
release_branches: master,main,develop
pre_release_branches: .*
Suggested Fix
When on a prerelease branch, check if the previous tag is already a prerelease with the same or higher version bump applied. If so, use prerelease instead of pre${bump}:
if (isPrerelease && previousVersion.prerelease.length > 0) {
// Already on a prerelease — just increment the rc number
releaseType = 'prerelease';
} else {
releaseType = isPrerelease ? `pre${bump}` : bump || defaultBump;
}
Related Issues
Bug Description
When on a prerelease branch, conventional commit messages (e.g.,
fix:,feat:) cause the version number to bump instead of incrementing the prerelease (rc) number.Expected Behavior
Given:
v1.1.1-rc.0fix: some bug fixExpected new tag:
v1.1.1-rc.1(rc increment)Actual Behavior
Actual new tag:
v1.1.2-rc.0(patch bump + rc reset)Root Cause
In
src/action.ts, when a conventional commit bump is detected on a prerelease branch:semver.inc("1.1.1-rc.0", "prepatch", "rc")returns1.1.2-rc.0— it bumps the patch version and resets the rc counter.The correct behavior when the previous tag is already a prerelease at the same or higher bump level should be to use
prereleaseas the release type:semver.inc("1.1.1-rc.0", "prerelease", "rc")returns1.1.1-rc.1The version bump from conventional commits should only be applied on the first prerelease (e.g., going from
v1.1.0release tov1.1.1-rc.0), not on subsequent prereleases where the bump has already been applied.Configuration
Suggested Fix
When on a prerelease branch, check if the previous tag is already a prerelease with the same or higher version bump applied. If so, use
prereleaseinstead ofpre${bump}:Related Issues