Skip to content

Commit

Permalink
Fix version parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
JrooTJunior committed Feb 7, 2021
1 parent 66f0868 commit aebccd1
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 11 deletions.
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,11 @@ clean:

.PHONY: isort
isort:
$(py) isort aiogram tests
$(py) isort aiogram tests scripts

.PHONY: black
black:
$(py) black aiogram tests
$(py) black aiogram tests scripts

.PHONY: flake8
flake8:
Expand Down
4 changes: 2 additions & 2 deletions aiogram/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,5 @@
"handler",
)

__version__ = "3.0.0a6"
__api_version__ = "5.0"
__version__ = "3.0.0-alpha.6"
__api_version__ = "4.9"
2 changes: 1 addition & 1 deletion docs/_package_version.md
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3.0.0a5
3.0.0a6
2 changes: 1 addition & 1 deletion poetry.lock

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

1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ furo = "^2020.11.15-beta.17"
sphinx-prompt = "^1.3.0"
Sphinx-Substitution-Extensions = "^2020.9.30"
black = "^20.8b1"
toml = "^0.10.2"

[tool.poetry.extras]
fast = ["uvloop"]
Expand Down
25 changes: 20 additions & 5 deletions scripts/bump_versions.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,33 @@
import re
from pathlib import Path

from poetry.factory import Factory
from poetry.masonry.metadata import Metadata
import toml

BASE_PATTERN = r'({variable} = ")[a-z0-9.+]+(")'
PACKAGE_VERSION = re.compile(BASE_PATTERN.format(variable="__version__"))
API_VERSION = re.compile(BASE_PATTERN.format(variable="__api_version__"))

STAGE_MAPPING = {
"alpha": "a",
"beta": "b",
}


def get_package_version() -> str:
poetry_instance = Factory().create_poetry(Path.cwd())
meta: Metadata = Metadata.from_package(poetry_instance.package)
return meta.version
data = toml.load(Path("pyproject.toml").absolute())
raw_version: str = data["tool"]["poetry"]["version"]
if "-" not in raw_version:
return raw_version

version, stage_build = raw_version.split("-", maxsplit=1)
if stage_build:
stage, build = stage_build.split(".")
if stage_str := STAGE_MAPPING.get(stage):
version += f"{stage_str}{build}"
else:
return raw_version

return version


def get_telegram_api_version() -> str:
Expand Down

0 comments on commit aebccd1

Please sign in to comment.