Initialize CI and release workflows; add version bumping scripts

This commit is contained in:
SergeantPanda 2025-04-10 11:25:24 -05:00
parent 07485f87a3
commit 6d0e51ed34
6 changed files with 217 additions and 1 deletions

62
scripts/bump_version.py Normal file
View file

@ -0,0 +1,62 @@
#!/usr/bin/env python
"""
Bumps the version number according to semantic versioning.
Usage: python bump_version.py [major|minor|patch]
"""
import re
import sys
from pathlib import Path
def bump_version(version_type='patch'):
version_file = Path(__file__).parent.parent / "version.py"
content = version_file.read_text()
# Extract version
version_match = re.search(r"__version__ = '(\d+)\.(\d+)\.(\d+)'", content)
if not version_match:
print("Could not find version number in version.py")
return
major, minor, patch = map(int, version_match.groups())
# Update version based on type
if version_type == 'major':
major += 1
minor = 0
patch = 0
elif version_type == 'minor':
minor += 1
patch = 0
else: # patch
patch += 1
new_version = f"{major}.{minor}.{patch}"
# Update version in file
new_content = re.sub(
r"__version__ = '\d+\.\d+\.\d+'",
f"__version__ = '{new_version}'",
content
)
# Reset build number
new_content = re.sub(
r"__build__ = '\d+'",
"__build__ = '0'",
new_content
)
version_file.write_text(new_content)
print(f"Version bumped to {new_version}")
return new_version
if __name__ == "__main__":
version_type = 'patch'
if len(sys.argv) > 1:
version_type = sys.argv[1].lower()
if version_type not in ('major', 'minor', 'patch'):
print("Invalid version type. Use major, minor, or patch.")
sys.exit(1)
bump_version(version_type)

View file

@ -0,0 +1,33 @@
#!/usr/bin/env python
"""
Increments the build number in version.py
"""
import re
import os
from pathlib import Path
def increment_build():
version_file = Path(__file__).parent.parent / "version.py"
content = version_file.read_text()
# Extract build number
build_match = re.search(r"__build__ = '(\d+)'", content)
if not build_match:
print("Could not find build number in version.py")
return
build = int(build_match.group(1))
new_build = str(build + 1)
# Update build number
new_content = re.sub(
r"__build__ = '\d+'",
f"__build__ = '{new_build}'",
content
)
version_file.write_text(new_content)
print(f"Build number incremented to {new_build}")
if __name__ == "__main__":
increment_build()