Skip to content

Commit

Permalink
chore: update version_checker.py to publish release candidate versions
Browse files Browse the repository at this point in the history
  • Loading branch information
pablojhl committed Jan 14, 2025
1 parent 0e1d8cb commit 484b2cc
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 24 deletions.
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ dev-dependencies = [
"pytest-cov>=4,<7",
"pylint>=2.17,<3.4",
"nada-mir-proto[dev]",
"tomli",
"requests",
"tomli>=2.2.0",
"requests>=2.32.3",
"typing_extensions~=4.12.2",
"ruff>=0.8.0"
]
Expand Down
17 changes: 4 additions & 13 deletions scripts/version_checker.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,12 @@
import os
import requests
from packaging import version
import json

from packaging.version import Version
import json


def get_public_version(project_name: str, is_test=False) -> Version:
response = requests.get(
f'https://{"test." if is_test else ""}pypi.org/pypi/{project_name}/json'
)
def get_public_version(project_name: str) -> Version:
response = requests.get(f"https://pypi.org/pypi/{project_name}/json")
if response.status_code == 200:
return version.parse(json.loads(response.content)["info"]["version"])
else:
Expand All @@ -23,21 +20,15 @@ def get_public_version(project_name: str, is_test=False) -> Version:

if __name__ == "__main__":
pyproject_toml_path = sys.argv[1]
test_regex = sys.argv[2] if len(sys.argv) > 2 else None
with open(pyproject_toml_path, "rb") as f:
project = tomli.load(f)

project_version = version.parse(project["project"]["version"])
is_test = False
if test_regex:
if re.compile(test_regex).search(str(project_version)):
is_test = True
public_project_version = get_public_version(project["project"]["name"], is_test)
public_project_version = get_public_version(project["project"]["name"])

with open(os.environ["GITHUB_OUTPUT"], "at") as f:
f.write(
f"local_version_is_higher={str(project_version > public_project_version).lower()}\n"
)
f.write(f"local_version={str(project_version)}\n")
f.write(f"public_version={str(public_project_version)}\n")
f.write(f"is_test={str(is_test).lower()}\n")
48 changes: 39 additions & 9 deletions uv.lock

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

0 comments on commit 484b2cc

Please sign in to comment.