Skip to content

Commit d3673f3

Browse files
Update version detection logic and documentation for accurate version bumping
1 parent c6233a3 commit d3673f3

File tree

4 files changed

+36
-28
lines changed

4 files changed

+36
-28
lines changed

.github/VERSION-DETECTION.md

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ This file demonstrates how the automated version detection works with different
44

55
## Branch-Based Version Detection
66

7-
### Major Version Bump (v0.10.2 → v0.11.0)
7+
### Minor Version Bump (v0.10.2 → v0.11.0)
88
**Trigger**: Merging from `feat*` branches
99

1010
```bash
@@ -16,10 +16,10 @@ git commit -m "add user profile management"
1616
git push origin feat/new-user-authentication
1717

1818
# Create PR and merge to master
19-
# Result: Automatic major version bump v0.10.2 → v0.11.0
19+
# Result: Automatic minor version bump v0.10.2 → v0.11.0
2020
```
2121

22-
### Minor Version Bump (v0.10.2 → v0.10.3)
22+
### Patch Version Bump (v0.10.2 → v0.10.3)
2323
**Trigger**: Merging from any other branch
2424

2525
```bash
@@ -46,24 +46,25 @@ The system checks in this order:
4646
1. **Feature branches** (highest priority)
4747
- Checks merged branch names for `feat*` pattern
4848
- Also checks commit messages for `feat:` prefix
49-
- Results in major version bump
49+
- Results in minor version bump (Y)
5050

5151
2. **Everything else** (default)
5252
- All other branch merges and commits
53-
- Results in minor version bump
53+
- Results in patch version bump (Z)
5454

5555
## Example Scenarios
5656

5757
| Branch Name | Commit Message | Version Change | Reason |
5858
|-------------|----------------|----------------|---------|
59-
| `feat/auth` | "add login system" | v0.10.2 → v0.11.0 | feat branch |
60-
| `fix/bug` | "fix: resolve crash" | v0.10.2 → v0.10.3 | non-feat branch |
61-
| `docs/readme` | "docs: update guide" | v0.10.2 → v0.10.3 | non-feat branch |
62-
| `fix/bug` | "feat: add new feature" | v0.10.2 → v0.11.0 | feat in commit |
63-
| `refactor/code` | "refactor: improve structure" | v0.10.2 → v0.10.3 | non-feat branch |
59+
| `feat/auth` | "add login system" | v0.10.2 → v0.11.0 | feat branch (minor) |
60+
| `fix/bug` | "fix: resolve crash" | v0.10.2 → v0.10.3 | non-feat branch (patch) |
61+
| `docs/readme` | "docs: update guide" | v0.10.2 → v0.10.3 | non-feat branch (patch) |
62+
| `fix/bug` | "feat: add new feature" | v0.10.2 → v0.11.0 | feat in commit (minor) |
63+
| `refactor/code` | "refactor: improve structure" | v0.10.2 → v0.10.3 | non-feat branch (patch) |
6464

6565
This ensures that:
66-
- ✅ New features always increment major version (minor number)
67-
- ✅ Bug fixes and other changes increment minor version (patch number)
66+
- ✅ New features always increment minor version (Y number)
67+
- ✅ Bug fixes and other changes increment patch version (Z number)
68+
- ✅ Major version (X) is only incremented manually
6869
- ✅ Documentation and dependency updates don't trigger releases
6970
- ✅ No manual version management needed

.github/workflows/AUTO-RELEASE.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,10 @@ on:
1010
release_type:
1111
description: 'Type of release'
1212
required: true
13-
default: 'minor'
13+
default: 'patch'
1414
type: choice
1515
options:
16+
- patch
1617
- minor
1718
- major
1819

.github/workflows/AUTO-VERSION.yml

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -81,15 +81,15 @@ jobs:
8181
# Determine version type
8282
VERSION_TYPE="${{ github.event.inputs.release_type }}"
8383
if [ "$VERSION_TYPE" = "auto" ] || [ -z "$VERSION_TYPE" ]; then
84-
# Check for feat branches first (major version bump)
84+
# Check for feat branches first (minor version bump - Y)
8585
if echo "$MERGED_BRANCHES" | grep -i "^feat\|/feat"; then
86-
VERSION_TYPE="major"
86+
VERSION_TYPE="minor"
8787
# Check for feat in commit messages as fallback
8888
elif echo "$COMMIT_MESSAGES" | grep -i "^feat\|feat:"; then
89-
VERSION_TYPE="major"
90-
# Everything else is minor
91-
else
9289
VERSION_TYPE="minor"
90+
# Everything else is patch (Z)
91+
else
92+
VERSION_TYPE="patch"
9393
fi
9494
fi
9595
@@ -104,10 +104,10 @@ jobs:
104104
105105
case $VERSION_TYPE in
106106
major)
107-
NEW_VERSION="v${MAJOR}.$((MINOR + 1)).0"
107+
NEW_VERSION="v$((MAJOR + 1)).0.0"
108108
;;
109109
minor)
110-
NEW_VERSION="v${MAJOR}.${MINOR}.$((PATCH + 1))"
110+
NEW_VERSION="v${MAJOR}.$((MINOR + 1)).0"
111111
;;
112112
patch)
113113
NEW_VERSION="v${MAJOR}.${MINOR}.$((PATCH + 1))"
@@ -173,8 +173,9 @@ jobs:
173173
4. 🧹 Release branch automatically cleaned up
174174
175175
🔍 Version Detection Logic
176-
- `major`: Merges from feat* branches or feat: in commits (v0.10.2 → v0.11.0)
177-
- `minor`: All other changes (v0.10.2 → v0.10.3)
176+
- `major`: Manual releases only (v0.10.2 → v1.0.0)
177+
- `minor`: Merges from feat* branches or feat: in commits (v0.10.2 → v0.11.0)
178+
- `patch`: All other changes (v0.10.2 → v0.10.3)
178179
179180
**This PR is safe to auto-merge - it only contains version updates.**
180181

README.md

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -245,12 +245,12 @@ You can also trigger releases manually via GitHub Actions UI:
245245
To help with automatic version detection, use these patterns:
246246

247247
```bash
248-
# Minor version (v0.10.2 → v0.10.3) - Most common
248+
# Patch version (v0.10.2 → v0.10.3) - Most common
249249
git commit -m "fix: resolve issue with force push"
250250
git commit -m "docs: update README"
251251
git commit -m "refactor: improve code structure"
252252
253-
# Major version (v0.10.2 → v0.11.0) - Feature branches or feat commits
253+
# Minor version (v0.10.2 → v0.11.0) - Feature branches or feat commits
254254
# Create feature branch:
255255
git checkout -b feat/new-functionality
256256
git commit -m "add new amend functionality"
@@ -262,20 +262,25 @@ git commit -m "feat: add new amend functionality"
262262

263263
The system prioritizes **branch names** for version detection:
264264

265-
- **`feat/*` branches** → **Major version bump** (v0.10.2 → v0.11.0)
265+
- **`feat/*` branches** → **Minor version bump** (v0.10.2 → v0.11.0)
266266
```bash
267267
git checkout -b feat/new-feature
268-
# When merged to master → major version bump
268+
# When merged to master → minor version bump
269269
```
270270

271-
- **Other branches** → **Minor version bump** (v0.10.2 → v0.10.3)
271+
- **Other branches** → **Patch version bump** (v0.10.2 → v0.10.3)
272272
```bash
273273
git checkout -b fix/bug-fix
274274
git checkout -b docs/update-readme
275275
git checkout -b refactor/cleanup
276-
# When merged to master → minor version bump
276+
# When merged to master → patch version bump
277277
```
278278

279+
**🔢 Major Version Handling**
280+
- **Major versions** (X in vX.Y.Z) are only incremented manually
281+
- Use **Actions** → **Auto-Release** → **Run workflow** and select "major"
282+
- This is reserved for breaking changes or significant API changes
283+
279284
### 🧪 Testing with Test Branches
280285

281286
For testing changes before they reach master:

0 commit comments

Comments
 (0)