ports/ci/bump_dev.py
cătălin 3a4c8ea2fa
Some checks failed
continuous-integration/drone/push Build is failing
ci: make pylint hook local
2022-10-17 17:59:27 +02:00

38 lines
1.2 KiB
Python

#!/usr/bin/env python3
import sys
import os
from pip_versions import core
from sh import poetry # pylint: disable=no-name-in-module
from decouple import config
username = config("REGISTRY_USERNAME")
password = config("REGISTRY_PASSWORD")
package_name = config("PACKAGE_NAME", "ports")
if not (index_url := os.getenv("EXTRA_INDEX_URL")):
os.environ[
"EXTRA_INDEX_URL"
] = "https://git.roboces.dev/api/packages/catalin/pypi/simple"
def main(): # pylint: disable=missing-function-docstring
current_version = poetry("version", _tty_out=False).split()[-1]
if "dev" in current_version:
print("Already on dev version")
sys.exit(1)
dev_versions_of_current_version = sorted(
x.version.dev
for x in core.find_versions(package_name=package_name)
if x and x.version.base_version == current_version
)
if not dev_versions_of_current_version:
dev_versions_of_current_version = [0]
last_dev_version = max(dev_versions_of_current_version)
new_version = f"{current_version}.dev{last_dev_version + 1}"
poetry("version", new_version)
print(f"Bumped version to {new_version}")
if __name__ == "__main__":
main()