|
| 1 | +# Semantic Versioning with Conventional Commits |
| 2 | + |
| 3 | +This repository uses automated semantic versioning based on conventional commits. The version numbers are automatically calculated and tagged when the `production` branch is updated. |
| 4 | + |
| 5 | +## How it works |
| 6 | + |
| 7 | +### Conventional Commit Format |
| 8 | + |
| 9 | +Commits should follow the [Conventional Commits](https://www.conventionalcommits.org/) specification: |
| 10 | + |
| 11 | +``` |
| 12 | +<type>[optional scope]: <description> |
| 13 | +
|
| 14 | +[optional body] |
| 15 | +
|
| 16 | +[optional footer(s)] |
| 17 | +``` |
| 18 | + |
| 19 | +### Commit Types and Version Impact |
| 20 | + |
| 21 | +| Commit Type | Version Bump | Description | |
| 22 | +|-------------|--------------|-------------| |
| 23 | +| `feat:` | Minor (x.Y.z) | New features | |
| 24 | +| `fix:` | Patch (x.y.Z) | Bug fixes | |
| 25 | +| `docs:` | Patch (x.y.Z) | Documentation changes | |
| 26 | +| `style:` | Patch (x.y.Z) | Code style changes (formatting, etc.) | |
| 27 | +| `refactor:` | Patch (x.y.Z) | Code refactoring | |
| 28 | +| `perf:` | Patch (x.y.Z) | Performance improvements | |
| 29 | +| `test:` | Patch (x.y.Z) | Test additions or updates | |
| 30 | +| `build:` | Patch (x.y.Z) | Build system changes | |
| 31 | +| `ci:` | Patch (x.y.Z) | CI/CD changes | |
| 32 | +| `chore:` | Patch (x.y.Z) | Maintenance tasks | |
| 33 | +| `BREAKING CHANGE:` | Major (X.y.z) | Breaking changes (in commit body or footer) | |
| 34 | +| `!` after type | Major (X.y.z) | Breaking changes (e.g., `feat!:` or `fix!:`) | |
| 35 | + |
| 36 | +### Examples |
| 37 | + |
| 38 | +```bash |
| 39 | +# Minor version bump (2.0.0 → 2.1.0) |
| 40 | +feat: add user authentication system |
| 41 | + |
| 42 | +# Patch version bump (2.0.0 → 2.0.1) |
| 43 | +fix: resolve login timeout issue |
| 44 | + |
| 45 | +# Major version bump (2.0.0 → 3.0.0) |
| 46 | +feat!: redesign user API with breaking changes |
| 47 | + |
| 48 | +# Or using footer: |
| 49 | +feat: redesign user API |
| 50 | + |
| 51 | +BREAKING CHANGE: User API endpoints have changed |
| 52 | +``` |
| 53 | + |
| 54 | +## Workflow Trigger |
| 55 | + |
| 56 | +The semantic versioning workflow is triggered when: |
| 57 | + |
| 58 | +1. **Push to production branch** - Automatic versioning and release |
| 59 | +2. **Manual workflow dispatch** - Can be triggered manually from GitHub Actions |
| 60 | + |
| 61 | +## What happens during a release |
| 62 | + |
| 63 | +1. **Analyze commits** - Parse commit messages since the last tag |
| 64 | +2. **Calculate version** - Determine next version based on commit types |
| 65 | +3. **Create tag** - Tag the commit with the new version (e.g., `v2.1.0`) |
| 66 | +4. **Generate changelog** - Update `CHANGELOG.md` with release notes |
| 67 | +5. **Create GitHub release** - Create a GitHub release with generated notes |
| 68 | +6. **Update wiki** - Update the project wiki with release information |
| 69 | + |
| 70 | +## Version History |
| 71 | + |
| 72 | +The project started with version `v2.0.0`. All subsequent versions follow semantic versioning: |
| 73 | + |
| 74 | +- **Major** (X.y.z): Breaking changes |
| 75 | +- **Minor** (x.Y.z): New features (backward compatible) |
| 76 | +- **Patch** (x.y.Z): Bug fixes (backward compatible) |
| 77 | + |
| 78 | +## Deployment Integration |
| 79 | + |
| 80 | +The semantic versioning workflow integrates with the existing Google Cloud Run deployment workflow: |
| 81 | + |
| 82 | +1. Semantic versioning runs first on `production` branch push |
| 83 | +2. Creates version tag and release notes |
| 84 | +3. The existing deployment workflow can reference the tagged version |
| 85 | + |
| 86 | +## Best Practices |
| 87 | + |
| 88 | +1. **Use descriptive commit messages** - Clear, concise descriptions help generate better release notes |
| 89 | +2. **Follow the conventional format** - Ensures proper version bumping |
| 90 | +3. **Include breaking change notes** - Use `BREAKING CHANGE:` in commit body for major version bumps |
| 91 | +4. **Test before merging to production** - Only merge tested changes to the production branch |
| 92 | +5. **Review generated changelogs** - Check the auto-generated changelog for accuracy |
| 93 | + |
| 94 | +## Troubleshooting |
| 95 | + |
| 96 | +### No version bump occurs |
| 97 | +- Ensure commits follow conventional commit format |
| 98 | +- Check that commits have occurred since the last tag |
| 99 | +- Verify the workflow has proper permissions |
| 100 | + |
| 101 | +### Incorrect version bump |
| 102 | +- Review commit types in the commit messages |
| 103 | +- Check for `BREAKING CHANGE:` or `!` indicators |
| 104 | +- Ensure conventional commit format is followed |
| 105 | + |
| 106 | +### Wiki update fails |
| 107 | +- Check repository permissions for wiki access |
| 108 | +- Verify the wiki is enabled for the repository |
0 commit comments