Version Management
Version Management¶
This document describes how version numbers are managed in the DataBeak project.
Current Approach - Script-Based Version Sync¶
1. Single Source of Truth¶
- The primary version is defined in
pyproject.toml
underproject.version
- All other files are synchronized from this single source
2. Dynamic Version Loading¶
The application uses importlib.metadata
to read the version at runtime:
# In src/databeak/_version.py
import importlib.metadata
try:
__version__ = importlib.metadata.version("databeak")
except importlib.metadata.PackageNotFoundError:
# Fallback for development mode
__version__ = "1.0.2-dev"
3. Version Synchronization Script¶
Run this command to sync versions across all files:
# Using uv (recommended)
uv run sync-versions
# Or directly with Python
python scripts/sync_versions.py
The script automatically updates:
package.json
- For npm/MCP registry compatibilitysrc/databeak/_version.py
- Fallback version for development
Release Workflow¶
Simple 3-Step Process¶
- Update the version in pyproject.toml:
- Sync all other files:
- Commit and tag:
Files That Are Synchronized¶
- pyproject.toml - Primary source of truth ✅
- package.json - Synced automatically 🔄
- src/databeak/_version.py - Synced automatically 🔄
Benefits¶
- Simplicity - Easy to understand and maintain
- Reliability - No complex external tool dependencies
- Consistency - One source of truth prevents version mismatches
- Runtime accuracy - Code always uses the actual installed package version
- Development friendly - Fallback version for development mode
Advanced Options (Future)¶
While the current script-based approach works well, you could consider these tools for more automation:
- semantic-release - Fully automated releases based on commit messages
- hatch version - Built into the build system
- GitHub Actions - Automate the entire release process
Example GitHub Action Workflow¶
# .github/workflows/release.yml
name: Release
on:
push:
tags: ['v*']
jobs:
release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: astral-sh/setup-uv@v4
- run: uv sync
- run: uv run sync-versions
- run: uv build
- run: uv publish
Best Practices¶
- Always run
uv run sync-versions
after changing the version in pyproject.toml - Use semantic versioning (MAJOR.MINOR.PATCH)
- Test the sync in your development environment before releases
- Keep the sync script simple and maintainable
- Document version changes in CHANGELOG.md