feat: automated version badge updates and CI/CD improvements
Some checks failed
CI/CD Pipeline / CI Pipeline (push) Failing after 16m21s

This commit is contained in:
2026-04-06 19:07:02 +02:00
parent 96cbfc99bb
commit c8b0dbd0a1
4 changed files with 69 additions and 4 deletions

View File

@@ -19,6 +19,10 @@ on:
- 'doc/**'
- 'adr/**'
- '.gitea/**'
- 'documentation/**'
- '*.md'
- '.vibe/**'
- 'features/**'
pull_request:
branches:
- main
@@ -28,6 +32,10 @@ on:
- 'doc/**'
- 'adr/**'
- '.gitea/**'
- 'documentation/**'
- '*.md'
- '.vibe/**'
- 'features/**'
# cancel any previously-started runs of this workflow on the same branch
concurrency:
@@ -125,7 +133,7 @@ jobs:
if [ "$VERSION_BUMPED" = "true" ]; then
git config --global user.name "CI Bot"
git config --global user.email "ci@arcodange.fr"
git add VERSION cmd/server/main.go
git add VERSION cmd/server/main.go README.md
git commit -m "chore: auto version bump [skip ci]" || echo "No changes to commit"
git push
fi

View File

@@ -1,8 +1,8 @@
# DanceLessonsCoach
[![Build Status](https://gitea.arcodange.fr/api/badges/arcodange/dance-lessons-coach/status)](https://gitea.arcodange.fr/arcodange/dance-lessons-coach)
[![Go Report Card](https://goreportcard.com/badge/github.com/arcodange/dance-lessons-coach)](https://goreportcard.com/report/github.com/arcodange/dance-lessons-coach)
[![Version](https://img.shields.io/badge/version-1.1.1-blue.svg)](https://gitea.arcodange.fr/arcodange/dance-lessons-coach/releases)
[![Build Status](https://gitea.arcodange.fr/api/badges/arcodange/DanceLessonsCoach/status)](https://gitea.arcodange.fr/arcodange/DanceLessonsCoach)
[![Go Report Card](https://goreportcard.com/badge/github.com/arcodange/DanceLessonsCoach)](https://goreportcard.com/report/github.com/arcodange/DanceLessonsCoach)
[![Version](https://img.shields.io/badge/version-1.3.1-blue.svg)](https://gitea.arcodange.fr/arcodange/DanceLessonsCoach/releases)
[![License](https://img.shields.io/badge/license-MIT-green.svg)](LICENSE)
A Go project demonstrating idiomatic package structure, CLI implementation, and JSON API with Chi router.

View File

@@ -708,6 +708,43 @@ docker compose -f docker-compose.cicd-test.yml up
7. **Multi-Arch Builds**: Support ARM64, Windows builds
8. **Matrix Testing**: Test across multiple Go versions
## Automated Version Badge Workflow
The CI/CD pipeline includes an automated workflow for maintaining version badges in README.md:
```mermaid
graph TD
A[Developer Pushes Commit] --> B{Commit Type?}
B -->|feat:| C[Bump MINOR version]
B -->|fix:| D[Bump PATCH version]
B -->|breaking:| E[Bump MAJOR version]
B -->|other| F[No version bump]
C --> G[Update VERSION file]
D --> G[Update VERSION file]
E --> G[Update VERSION file]
G --> H[Update main.go Swagger version]
H --> I[Update README.md version badge]
I --> J[Commit & Push changes]
J --> K[Skip CI to prevent loops]
```
### Workflow Details
1. **Trigger**: Push events to main branch with specific commit message patterns
2. **Version Detection**: Parses commit messages for conventional commit types
3. **Automatic Bumping**: Increments version based on commit type (feat → minor, fix → patch, breaking → major)
4. **File Updates**: Updates VERSION file, Swagger documentation, and README.md badge
5. **Automatic Commit**: CI Bot commits changes with `[skip ci]` to prevent infinite loops
6. **Push**: Automatically pushes the version update back to the repository
### Benefits
- **Automatic Maintenance**: README.md version badge always stays current
- **No Manual Intervention**: Developers don't need to remember to update badges
- **Consistent Versioning**: Follows semantic versioning automatically
- **Audit Trail**: Version bumps are tracked in git history
- **CI/CD Integration**: Seamlessly integrated with existing pipeline
## References
- [Gitea Actions Documentation](https://docs.gitea.com/next/usage/actions/)

View File

@@ -130,4 +130,24 @@ if [ -f "$MAIN_GO" ]; then
echo "✅ Updated Swagger version in main.go"
fi
# Update README.md version badge
README_MD="README.md"
if [ -f "$README_MD" ]; then
# Create temporary file
TMP_FILE=$(mktemp)
# Use awk to update version badge
awk -v new_version="$NEW_VERSION" '{
if ($0 ~ /Version.*badge.*version/) {
print "[![Version](https://img.shields.io/badge/version-" new_version "-blue.svg)](https://gitea.arcodange.fr/arcodange/DanceLessonsCoach/releases)"
} else {
print $0
}
}' "$README_MD" > "$TMP_FILE"
# Replace original file
mv "$TMP_FILE" "$README_MD"
echo "✅ Updated version badge in README.md"
fi
echo "🎉 Version bump complete: $NEW_VERSION"