From c8b0dbd0a1a644b843c9f25186b303489ae120ff Mon Sep 17 00:00:00 2001 From: Gabriel Radureau Date: Mon, 6 Apr 2026 19:07:02 +0200 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20feat:=20automated=20version=20badge?= =?UTF-8?q?=20updates=20and=20CI/CD=20improvements?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitea/workflows/ci-cd.yaml | 10 ++++++++- README.md | 6 ++--- adr/0016-ci-cd-pipeline-design.md | 37 +++++++++++++++++++++++++++++++ scripts/version-bump.sh | 20 +++++++++++++++++ 4 files changed, 69 insertions(+), 4 deletions(-) diff --git a/.gitea/workflows/ci-cd.yaml b/.gitea/workflows/ci-cd.yaml index 9468e2e..8686d57 100644 --- a/.gitea/workflows/ci-cd.yaml +++ b/.gitea/workflows/ci-cd.yaml @@ -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 diff --git a/README.md b/README.md index bffb924..101f1a9 100644 --- a/README.md +++ b/README.md @@ -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. diff --git a/adr/0016-ci-cd-pipeline-design.md b/adr/0016-ci-cd-pipeline-design.md index 1502f7c..3f556bd 100644 --- a/adr/0016-ci-cd-pipeline-design.md +++ b/adr/0016-ci-cd-pipeline-design.md @@ -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/) diff --git a/scripts/version-bump.sh b/scripts/version-bump.sh index 57cf90b..e9285b8 100755 --- a/scripts/version-bump.sh +++ b/scripts/version-bump.sh @@ -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"