Skip to content

Commit fb31c4d

Browse files
committed
docs: add semantic versioning, changelog, and release automation documentation
1 parent a4e364a commit fb31c4d

File tree

1 file changed

+161
-11
lines changed

1 file changed

+161
-11
lines changed

README.md

Lines changed: 161 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,155 @@ gh run view --web
246246
- Ensure PAT_TOKEN has required scopes
247247
- Check workflow permissions in yml files
248248

249+
## 🔄 Semantic Versioning
250+
251+
This project follows [Semantic Versioning 2.0.0](https://semver.org/) principles. Version numbers are structured as MAJOR.MINOR.PATCH:
252+
253+
1. **MAJOR** version - Incremented for incompatible API changes
254+
2. **MINOR** version - Incremented for backward-compatible new functionality
255+
3. **PATCH** version - Incremented for backward-compatible bug fixes
256+
257+
Additional labels for pre-release and build metadata are available as extensions to the MAJOR.MINOR.PATCH format.
258+
259+
### Version Bumping Rules
260+
261+
- Breaking changes (MAJOR): `BREAKING CHANGE:` in commit footer or `!` after type/scope
262+
- New features (MINOR): `feat:` commit type
263+
- Bug fixes (PATCH): `fix:` commit type
264+
- No version bump: `chore:`, `docs:`, `style:`, `refactor:`, `perf:`, `test:`
265+
266+
## 🚀 Python Semantic Release
267+
268+
We use [Python Semantic Release](https://python-semantic-release.readthedocs.io/en/latest/) for automated versioning and changelog generation. Key features:
269+
270+
- Automatic version bumping based on commit messages
271+
- Changelog generation following Keep a Changelog format
272+
- GitHub release creation and asset publishing
273+
- Support for pre-releases and build metadata
274+
275+
### Configuration
276+
277+
Configuration in `pyproject.toml` integrates our versioning and changelog standards:
278+
279+
```toml
280+
[tool.python_semantic_release]
281+
# Version Management
282+
version_variables = ["app/__init__.py:__version__"] # Update version in code
283+
version_toml = ["pyproject.toml:tool.poetry.version"] # Update version in pyproject.toml
284+
version_source = ["tag", "commit"] # Determine version from tags and commits
285+
major_on_zero = false # Follow SemVer for 0.x versions
286+
tag_format = "v{version}" # Git tag format (e.g., v1.0.0)
287+
288+
# Commit Parsing
289+
commit_parser = "conventional_commits" # Use Conventional Commits standard
290+
commit_author = "github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>"
291+
292+
# Changelog Management
293+
changelog_file = "CHANGELOG.md" # Keep a Changelog file
294+
changelog_sections = [ # Keep a Changelog categories
295+
"feature", # Maps to Added
296+
"fix", # Maps to Fixed
297+
"breaking", # Maps to Changed with breaking changes
298+
"documentation",
299+
"performance",
300+
"refactor"
301+
]
302+
303+
# Release Settings
304+
upload_to_repository = false
305+
build_command = "poetry build"
306+
tag_type = "annotated" # Use annotated tags for better documentation
307+
```
308+
309+
### Automatic Standards Compliance
310+
311+
1. **Semantic Versioning**:
312+
- Analyzes commit messages using Conventional Commits
313+
- Automatically determines version bumps:
314+
- `BREAKING CHANGE` → MAJOR
315+
- `feat:` → MINOR
316+
- `fix:` → PATCH
317+
- Creates appropriate Git tags
318+
319+
2. **Keep a Changelog**:
320+
- Maintains CHANGELOG.md in the standard format
321+
- Groups changes by type (Added, Changed, Fixed, etc.)
322+
- Includes release dates and version links
323+
- Keeps an Unreleased section for upcoming changes
324+
- Links to Git comparisons between versions
325+
326+
### Manual Release Commands
327+
328+
```bash
329+
# Check what the next version would be
330+
poetry run semantic-release version --noop
331+
332+
# Create a new version (local only)
333+
poetry run semantic-release version
334+
335+
# Create and publish a new release
336+
poetry run semantic-release publish
337+
```
338+
339+
### Environment Setup
340+
341+
Required environment variables:
342+
- `GH_TOKEN`: GitHub Personal Access Token with `repo` scope
343+
- For fine-grained tokens: `contents` permission required
344+
345+
## 🔄 Changelog Guidelines
346+
347+
We follow the [Keep a Changelog](https://keepachangelog.com/en/1.1.0/) principles for maintaining our CHANGELOG.md. This ensures our changelog is:
348+
349+
### Guiding Principles
350+
351+
- Written for humans, not machines
352+
- Easy to link to any section
353+
- One sub-section per version
354+
- List releases in reverse-chronological order
355+
- Include release date for each version
356+
- Group changes by type
357+
- Mention whether we follow Semantic Versioning
358+
359+
### Types of Changes
360+
361+
- `Added` - New features
362+
- `Changed` - Changes in existing functionality
363+
- `Deprecated` - Soon-to-be removed features
364+
- `Removed` - Now removed features
365+
- `Fixed` - Any bug fixes
366+
- `Security` - In case of vulnerabilities
367+
368+
### Good Practices
369+
370+
- Keep an `Unreleased` section at the top for tracking upcoming changes
371+
- Never use commit log diffs as changelog entries
372+
- Always write clear, human-friendly descriptions
373+
- Use ISO 8601 format for dates (YYYY-MM-DD)
374+
- Make it clear when breaking changes occur
375+
- Keep entries consistent and well-organized
376+
- Link to issues, PRs, and other relevant information
377+
378+
### Example Entry
379+
380+
```markdown
381+
## [1.0.0] - 2024-01-02
382+
383+
### Added
384+
- New API endpoint for QR code generation
385+
- Support for custom QR code colors
386+
387+
### Changed
388+
- Improved error handling in API responses
389+
- Updated dependencies to latest versions
390+
391+
### Fixed
392+
- Issue with QR code size calculation
393+
- Memory leak in image processing
394+
395+
[1.0.0]: https://github.com/username/project/compare/v0.9.0...v1.0.0
396+
```
397+
249398
## 🔄 Workflow Architecture
250399

251400
```mermaid
@@ -266,13 +415,14 @@ flowchart TD
266415
H --> I[Semantic Release]
267416
I --> J{Released?}
268417
269-
J -->|Yes| K[Tag Validation]
418+
J -->|Yes| K[Create GitHub Release]
270419
J -->|No| L[Skip Publish]
271420
272421
subgraph "Skip Conditions"
273422
P[Skip if:] --> P1[github-actions bot]
274-
P --> P2[skip ci tag]
275-
P --> P3[chore release]
423+
P --> P2[semantic-release user]
424+
P --> P3[skip ci tag]
425+
P --> P4[chore release]
276426
end
277427
end
278428
@@ -311,12 +461,10 @@ flowchart TD
311461
- Prereleases
312462
- Force version bumps
313463
- Custom prerelease tokens
314-
315-
4. **Tag Validation** (.github/workflows/tag-validation.yml)
316-
- Validates tag authenticity
317-
- Ensures tags are created by GitHub Actions
318-
- Removes unauthorized tags
319-
- Verifies semantic versioning format
464+
- Skips when commit is from:
465+
- github-actions[bot]
466+
- semantic-release user
467+
- Contains [skip ci] tag
320468

321469
### Workflow Execution
322470

@@ -329,7 +477,7 @@ flowchart TD
329477
- Full pipeline executes
330478
- Changelog is updated
331479
- New release is created if needed
332-
- Tags are validated
480+
- Release is published to GitHub
333481

334482
3. **Manual Dispatch:**
335483
- Available for release workflow
@@ -339,7 +487,9 @@ flowchart TD
339487
### Skip Conditions
340488

341489
Workflows are skipped when:
342-
- Commit is from github-actions[bot]
490+
- Commit is from:
491+
- github-actions[bot]
492+
- semantic-release user
343493
- Commit message contains:
344494
- [skip ci]
345495
- chore(release)

0 commit comments

Comments
 (0)