Skip to content

Commit

Permalink
Add version bump script (#3)
Browse files Browse the repository at this point in the history
Adds a script, bumpversion.py, that can be used to bump versions to a
specific, specified version in one go.
  • Loading branch information
kbrgl authored Oct 26, 2024
1 parent 2b37091 commit 5a35a9b
Show file tree
Hide file tree
Showing 4 changed files with 64 additions and 4 deletions.
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,6 @@ lint:

test:
uv run pytest -ra tests/ -sv --cov=cartesia/ --log-cli-level=INFO

bump: # Use as `make bump version=<version>`
uv run -m bumpversion $(version)
41 changes: 41 additions & 0 deletions bumpversion.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
"""Bump the version of the package.
Usage: bumpversion.py <version>
<version> must be in the format of <major>.<minor>.<patch>[-<prelabel><preversion>]
"""

import re
import tomlkit
import sys
from cartesia.version import __version__

VERSION_REGEX = r"""(?x)
(?P<major>0|[1-9]\d*)\.
(?P<minor>0|[1-9]\d*)\.
(?P<patch>0|[1-9]\d*)
(?:
- # dash separator for pre-release section
(?P<prelabel>[a-zA-Z-]+) # pre-release label
(?P<preversion>0|[1-9]\d*) # pre-release version number
)? # pre-release section is optional
""" # Source: https://github.com/callowayproject/bump-my-version


def main(version: str):
assert re.match(VERSION_REGEX, version), "Invalid version format"

with open("pyproject.toml", "r") as f:
pyproject = tomlkit.load(f)

pyproject["project"]["version"] = version

with open("pyproject.toml", "w") as f:
tomlkit.dump(pyproject, f)

with open("cartesia/version.py", "w") as f:
f.write(f'__version__ = "{version}"\n')


if __name__ == "__main__":
main(sys.argv[1])
3 changes: 2 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "cartesia"
version = "0.1.0"
version = "1.0.14"
description = "The official Python library for the Cartesia API."
readme = "README.md"
requires-python = ">=3.9"
Expand All @@ -23,6 +23,7 @@ dev-dependencies = [
"setuptools>=75.2.0",
"twine>=5.1.1",
"wheel>=0.44.0",
"tomlkit>=0.13.2",
]

[tool.ruff]
Expand Down
21 changes: 18 additions & 3 deletions uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 5a35a9b

Please sign in to comment.