mathieudutour / mathieudutour/github-tag-action
Prerelease branch: conventional commits cause version bump instead of rc increment
- Dominant language
- TypeScript
- Stars
- 733
- Forks
- 227
- PR merge metrics
- No merged PRs in 30d
Description
## 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:
```typescript
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
```yaml
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}`:
```typescript
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
- #88 — same underlying problem
- #102 — fixed the no-bump case but not the conventional-commit-bump case
Contributor guide
Research direction
Start in src/action.ts and inspect how conventional-commit bumps are converted to a release type on prerelease branches. Verify the semver behavior for v1.1.1-rc.0 with a fix commit, then confirm that subsequent prereleases produce v1.1.1-rc.1 while the first prerelease still applies the intended version bump.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- git, github-actions, typescript
- Domain
- ci-cd, release
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Quiet
- Clarity
- Clearly specified
- Newbie friendliness
- 70/100