Version Files¶
Manage version numbers across your project files.
Overview¶
releasio automatically updates version numbers in multiple locations:
%%{init: {'theme': 'neutral'}}%%
graph TD
A[Version Bump] --> B[pyproject.toml]
A --> C[__init__.py]
A --> D[__version__.py]
A --> E[Other files]
Default Behavior¶
pyproject.toml¶
releasio always updates the version in pyproject.toml:
For Poetry projects:
Auto-Detection¶
releasio can automatically find and update version files:
Detected Patterns¶
| File | Pattern |
|---|---|
__init__.py |
__version__ = "1.2.3" |
__version__.py |
__version__ = "1.2.3" |
version.py |
__version__ = "1.2.3" |
_version.py |
__version__ = "1.2.3" |
Detection Locations¶
releasio searches in:
- Package root (
src/package/) - Project root
- Common subdirectories
Manual Configuration¶
Specify version files explicitly:
[version]
auto_detect_version_files = false
[[version.files]]
path = "src/mypackage/__init__.py"
pattern = '__version__ = "{version}"'
[[version.files]]
path = "src/mypackage/version.py"
pattern = 'VERSION = "{version}"'
Pattern Syntax¶
Use {version} as placeholder:
# Standard Python
pattern = '__version__ = "{version}"'
# With single quotes
pattern = "__version__ = '{version}'"
# Tuple format
pattern = 'VERSION = ({major}, {minor}, {patch})'
# Custom variable
pattern = 'PACKAGE_VERSION = "{version}"'
Common Patterns¶
Package __init__.py¶
[[version.files]]
path = "src/mypackage/__init__.py"
pattern = '__version__ = "{version}"'
Dedicated Version File¶
"""Version information."""
__version__ = "1.2.3"
VERSION = __version__
VERSION_TUPLE = (1, 2, 3)
[[version.files]]
path = "src/mypackage/_version.py"
pattern = '__version__ = "{version}"'
Multiple Variables¶
For files with multiple version references:
[[version.files]]
path = "src/mypackage/version.py"
patterns = [
'__version__ = "{version}"',
'VERSION = "{version}"',
]
Lock File Updates¶
Update lock files when version changes:
This runs:
| Tool | Command |
|---|---|
| uv | uv lock |
| Poetry | poetry lock --no-update |
| PDM | pdm lock |
Version Sources¶
Reading Current Version¶
releasio determines the current version from:
-
Git tags (highest priority)
-
pyproject.toml
-
Version files
Priority Order¶
Git tag v1.2.3
↓ (if exists)
Use tag version
↓ (if not)
Read pyproject.toml
↓ (if not)
Read __init__.py
Dynamic Versions¶
Some build backends support dynamic versions:
Hatchling¶
[project]
dynamic = ["version"]
[tool.hatch.version]
path = "src/mypackage/__init__.py"
releasio updates the source file:
[[version.files]]
path = "src/mypackage/__init__.py"
pattern = '__version__ = "{version}"'
Setuptools-scm¶
For projects using setuptools-scm, releasio creates git tags:
No version files needed - version comes from git tags.
Non-Python Files¶
Update version in other file types:
JSON Files¶
YAML Files¶
Markdown¶
Validation¶
releasio validates version consistency:
Output:
⚠️ Version mismatch detected:
pyproject.toml: 1.2.3
__init__.py: 1.2.2
Run 'releasio update --execute' to synchronize.
Troubleshooting¶
Version Not Updated¶
Causes:
- Pattern doesn't match file content
- File path is incorrect
- File permissions
Solution: Verify pattern matches exactly:
# Check current content
grep "__version__" src/mypackage/__init__.py
# Compare with pattern
# Pattern: __version__ = "{version}"
# File: __version__ = "1.2.3"
Multiple Matches¶
Solution: Use a more specific pattern:
Encoding Issues¶
Solution: Ensure UTF-8 encoding:
Best Practices¶
Do¶
- Keep version in one source of truth
- Use
pyproject.tomlas primary - Enable auto-detection for common patterns
- Use dynamic versions when possible
Don't¶
- Manually edit version numbers
- Have conflicting versions across files
- Use complex patterns that might break
- Forget to commit version changes
See Also¶
- Semantic Versioning - Version bump rules
- Pre-releases - Alpha/beta versions
- Configuration Reference - All options