|
| 1 | +# 🏷️ Versioning Strategy |
| 2 | + |
| 3 | +## Overview |
| 4 | + |
| 5 | +This project uses **Semantic Versioning (SemVer)** with automatic version bumping based on commit messages when merging to the `main` branch. |
| 6 | + |
| 7 | +## How It Works |
| 8 | + |
| 9 | +### Automatic Version Bumping |
| 10 | + |
| 11 | +When you merge a feature branch to `main`, the workflow automatically: |
| 12 | + |
| 13 | +1. **Analyzes commit messages** since the last tag |
| 14 | +2. **Determines the bump type** (major, minor, or patch) |
| 15 | +3. **Creates a new version tag** |
| 16 | +4. **Builds and publishes** containers with the new version |
| 17 | +5. **Creates a GitHub release** with release notes |
| 18 | + |
| 19 | +### Version Bump Rules |
| 20 | + |
| 21 | +The workflow scans commit messages to determine which version component to bump: |
| 22 | + |
| 23 | +| Commit Message Pattern | Bump Type | Example | |
| 24 | +|------------------------|-----------|---------| |
| 25 | +| `BREAKING CHANGE` or `major:` | **Major** (x.0.0) | `v1.2.3` → `v2.0.0` | |
| 26 | +| `feat:`, `feature:`, or `minor:` | **Minor** (0.x.0) | `v1.2.3` → `v1.3.0` | |
| 27 | +| All other commits | **Patch** (0.0.x) | `v1.2.3` → `v1.2.4` | |
| 28 | + |
| 29 | +### Examples |
| 30 | + |
| 31 | +#### Patch Release (Bug fixes, documentation, small changes) |
| 32 | +```bash |
| 33 | +git commit -m "fix: resolve sensor reading issue" |
| 34 | +git commit -m "docs: update README" |
| 35 | +git commit -m "chore: update dependencies" |
| 36 | +``` |
| 37 | +**Result:** `v1.2.3` → `v1.2.4` |
| 38 | + |
| 39 | +#### Minor Release (New features, backwards-compatible) |
| 40 | +```bash |
| 41 | +git commit -m "feat: add temperature alerts" |
| 42 | +git commit -m "feature: implement auto-refresh" |
| 43 | +``` |
| 44 | +**Result:** `v1.2.3` → `v1.3.0` |
| 45 | + |
| 46 | +#### Major Release (Breaking changes) |
| 47 | +```bash |
| 48 | +git commit -m "feat: redesign API |
| 49 | +
|
| 50 | +BREAKING CHANGE: API endpoints have changed" |
| 51 | +``` |
| 52 | +**Result:** `v1.2.3` → `v2.0.0` |
| 53 | + |
| 54 | +Or use the `major:` prefix: |
| 55 | +```bash |
| 56 | +git commit -m "major: complete rewrite of sensor parser" |
| 57 | +``` |
| 58 | +**Result:** `v1.2.3` → `v2.0.0` |
| 59 | + |
| 60 | +## Workflow Triggers |
| 61 | + |
| 62 | +### Main Branch (Automatic Versioning) |
| 63 | +- **Trigger:** Push to `main` (typically from merged PRs) |
| 64 | +- **Action:** Bumps version, builds containers, creates release |
| 65 | +- **Tags:** New semantic version (e.g., `v1.2.4`) |
| 66 | +- **Images:** |
| 67 | + - `ghcr.io/michaeltrip/lmsensors-daemonset-container:v1.2.4` |
| 68 | + - `ghcr.io/michaeltrip/lmsensors-daemonset-container:latest` |
| 69 | + - `ghcr.io/michaeltrip/lmsensors-web:v1.2.4` |
| 70 | + - `ghcr.io/michaeltrip/lmsensors-web:latest` |
| 71 | + |
| 72 | +### Feature Branches (Development) |
| 73 | +- **Trigger:** Push to `feature/**`, `fix/**`, `chore/**` |
| 74 | +- **Action:** Builds containers only (no release) |
| 75 | +- **Tags:** Branch-based (e.g., `feature-auth-abc1234`) |
| 76 | +- **Images:** `ghcr.io/michaeltrip/lmsensors-daemonset-container:feature-auth-abc1234` |
| 77 | + |
| 78 | +### Pull Requests |
| 79 | +- **Trigger:** PR opened/updated to `main` |
| 80 | +- **Action:** Builds containers only (no push) |
| 81 | +- **Purpose:** CI validation |
| 82 | + |
| 83 | +### Schedule |
| 84 | +- **Trigger:** Daily at 16:00 UTC |
| 85 | +- **Action:** Rebuilds latest containers |
| 86 | +- **Purpose:** Security updates, base image updates |
| 87 | + |
| 88 | +## Best Practices |
| 89 | + |
| 90 | +### 1. Use Conventional Commits |
| 91 | +Follow the [Conventional Commits](https://www.conventionalcommits.org/) specification: |
| 92 | + |
| 93 | +``` |
| 94 | +<type>: <description> |
| 95 | +
|
| 96 | +[optional body] |
| 97 | +
|
| 98 | +[optional footer] |
| 99 | +``` |
| 100 | + |
| 101 | +### 2. Plan Your Releases |
| 102 | +Before merging to `main`, consider: |
| 103 | +- What type of changes are included? |
| 104 | +- Should this be a major, minor, or patch release? |
| 105 | +- Are there breaking changes? |
| 106 | + |
| 107 | +### 3. Squash Merge Strategy |
| 108 | +When merging PRs, consider squashing commits and using a clear commit message: |
| 109 | + |
| 110 | +```bash |
| 111 | +feat: add real-time sensor monitoring |
| 112 | + |
| 113 | +- Implemented WebSocket connection |
| 114 | +- Added auto-refresh every 5 seconds |
| 115 | +- Updated UI with live indicator |
| 116 | +``` |
| 117 | + |
| 118 | +### 4. Review Before Merge |
| 119 | +The version bump happens automatically, so ensure: |
| 120 | +- All tests pass |
| 121 | +- Documentation is updated |
| 122 | +- Breaking changes are clearly marked |
| 123 | + |
| 124 | +## Manual Version Override |
| 125 | + |
| 126 | +If you need to create a specific version manually: |
| 127 | + |
| 128 | +```bash |
| 129 | +# Create and push a tag manually |
| 130 | +git tag v2.0.0 |
| 131 | +git push origin v2.0.0 |
| 132 | + |
| 133 | +# The workflow will use this tag for the next main branch push |
| 134 | +``` |
| 135 | + |
| 136 | +## Checking Current Version |
| 137 | + |
| 138 | +```bash |
| 139 | +# Get the latest version tag |
| 140 | +git describe --tags --abbrev=0 |
| 141 | + |
| 142 | +# List all version tags |
| 143 | +git tag -l "v*" --sort=-version:refname |
| 144 | +``` |
| 145 | + |
| 146 | +## Troubleshooting |
| 147 | + |
| 148 | +### Release Not Created |
| 149 | +Check if: |
| 150 | +1. You're pushing to `main` (not a feature branch) |
| 151 | +2. There are new commits since the last tag |
| 152 | +3. The workflow has `contents: write` permission |
| 153 | + |
| 154 | +### Wrong Version Bumped |
| 155 | +Review your commit messages: |
| 156 | +- Use `feat:` for features (minor bump) |
| 157 | +- Use `BREAKING CHANGE:` in commit body for major bumps |
| 158 | +- Regular commits default to patch bumps |
| 159 | + |
| 160 | +### Container Not Tagged |
| 161 | +Check the GitHub Actions logs: |
| 162 | +1. Go to Actions tab |
| 163 | +2. Click on the latest workflow run |
| 164 | +3. Review the "Determine tag" step output |
0 commit comments