-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds a script, bumpversion.py, that can be used to bump versions to a specific, specified version in one go.
- Loading branch information
Showing
4 changed files
with
64 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.