@@ -112,13 +112,32 @@ jobs:
112112 local base="${current%%-*}"
113113 IFS='.' read -r major minor patch <<< "$base"
114114
115- case "$bump_type" in
116- major) major=$((major + 1)); minor=0; patch=0 ;;
117- minor) minor=$((minor + 1)); patch=0 ;;
118- patch) patch=$((patch + 1)) ;;
119- esac
115+ # Check if current version already has the requested pre-release label
116+ local current_pre=""
117+ if [[ "$current" =~ -([a-z]+)\.[0-9]+$ ]]; then
118+ current_pre="${BASH_REMATCH[1]}"
119+ fi
120120
121- local new_base="${major}.${minor}.${patch}"
121+ local new_base
122+ if [[ "$PRERELEASE" != "none" && "$current_pre" == "$PRERELEASE" ]]; then
123+ # Same pre-release channel: keep base, increment counter
124+ # e.g. 0.12.0-next.1 → 0.12.0-next.2
125+ new_base="$base"
126+ elif [[ "$PRERELEASE" == "none" && -n "$current_pre" ]]; then
127+ # Promoting pre-release to stable: use base as-is
128+ # e.g. 0.12.0-next.3 → 0.12.0
129+ new_base="$base"
130+ else
131+ # Stable → stable bump, or stable → new pre-release
132+ # e.g. 0.11.0 + minor → 0.12.0
133+ # e.g. 0.11.0 + minor + next → 0.12.0-next.1
134+ case "$bump_type" in
135+ major) major=$((major + 1)); minor=0; patch=0 ;;
136+ minor) minor=$((minor + 1)); patch=0 ;;
137+ patch) patch=$((patch + 1)) ;;
138+ esac
139+ new_base="${major}.${minor}.${patch}"
140+ fi
122141
123142 if [[ "$PRERELEASE" != "none" ]]; then
124143 local existing
0 commit comments