Skip to content

Commit 2e0a50c

Browse files
authored
Merge pull request #7 from MichaelTrip/feature/ssd-temps
Adding SSD temp and fixing pipeline
2 parents 02d6902 + 1ca41e0 commit 2e0a50c

File tree

2 files changed

+203
-3
lines changed

2 files changed

+203
-3
lines changed

.github/workflows/build-dual-containers.yaml

Lines changed: 39 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,45 @@ jobs:
4545
LATEST_TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "v0.0.0")
4646
echo "Latest git tag: $LATEST_TAG"
4747
48-
# For main branch, use the git tag as docker tag
49-
DOCKER_TAG="$LATEST_TAG"
50-
GIT_TAG="$LATEST_TAG"
48+
# Extract version numbers (remove 'v' prefix)
49+
VERSION=${LATEST_TAG#v}
50+
IFS='.' read -r MAJOR MINOR PATCH <<< "$VERSION"
51+
52+
# Default to 0.0.0 if parsing fails
53+
MAJOR=${MAJOR:-0}
54+
MINOR=${MINOR:-0}
55+
PATCH=${PATCH:-0}
56+
57+
# Analyze commit messages since last tag to determine bump type
58+
if [ "$LATEST_TAG" != "v0.0.0" ]; then
59+
COMMITS=$(git log ${LATEST_TAG}..HEAD --pretty=format:"%s")
60+
else
61+
COMMITS=$(git log --pretty=format:"%s")
62+
fi
63+
64+
# Check for breaking changes or major version indicators
65+
if echo "$COMMITS" | grep -qiE "BREAKING CHANGE|major:"; then
66+
MAJOR=$((MAJOR + 1))
67+
MINOR=0
68+
PATCH=0
69+
BUMP_TYPE="major"
70+
# Check for features or minor version indicators
71+
elif echo "$COMMITS" | grep -qiE "^feat|^feature|minor:"; then
72+
MINOR=$((MINOR + 1))
73+
PATCH=0
74+
BUMP_TYPE="minor"
75+
# Default to patch version bump
76+
else
77+
PATCH=$((PATCH + 1))
78+
BUMP_TYPE="patch"
79+
fi
80+
81+
NEW_TAG="v${MAJOR}.${MINOR}.${PATCH}"
82+
echo "Bump type: $BUMP_TYPE"
83+
echo "New tag: $NEW_TAG"
84+
85+
DOCKER_TAG="$NEW_TAG"
86+
GIT_TAG="$NEW_TAG"
5187
else
5288
IS_MAIN="false"
5389

VERSIONING.md

Lines changed: 164 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,164 @@
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

Comments
 (0)