Skip to content

Commit

Permalink
refactor: Update get_version() function to filter versions starting w…
Browse files Browse the repository at this point in the history
…ith "0.2.0" and containing "b"
  • Loading branch information
carlos-rian-qd committed Oct 15, 2024
1 parent c0e36c7 commit 96efa4e
Showing 1 changed file with 8 additions and 17 deletions.
25 changes: 8 additions & 17 deletions .github/release.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,30 +6,21 @@


def get_version():
uri = "https://pypi.org/pypi/pysqlx-core/json"
for _ in range(3):
resp = httpx.get("https://pypi.org/pypi/pysqlx-core/json")
if resp.status_code == 200:
resp = httpx.get(uri)
if resp.is_success:
break
data: dict = resp.json()
json: dict = resp.json()

releases = data["releases"]
releases = json["releases"]
versions = sorted(
releases.keys(),
key=lambda x: int(x.replace(".", "").replace("b", "").replace("a", "")),
key=lambda x: int(x.replace(".", "").replace("b", "")),
reverse=True,
)
versions = [v for v in versions if "b" in v]

current_version = data["info"]["version"]

if versions:
if int(current_version.replace(".", "")) > int(
versions[0].split("b")[0].replace(".", "")
):
return current_version
return versions[0]

return current_version
versions = [v for v in versions if v.startswith("0.2.0") and "b" in v]
return versions.pop() if versions else "0.2.0b-1"


version: str = get_version()
Expand Down

0 comments on commit 96efa4e

Please sign in to comment.