Skip to content

Commit

Permalink
update ci, remove httpx
Browse files Browse the repository at this point in the history
  • Loading branch information
carlos-rian committed Oct 27, 2023
1 parent 0aeb004 commit dcf4daa
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 21 deletions.
17 changes: 10 additions & 7 deletions .github/prod.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,22 @@
import httpx
import toml
import json
import os
import urllib

import toml

with open("Cargo.toml", mode="r") as file:
text: str = file.read()


# convert get_version to use native python libs
def get_version():
uri = "https://pypi.org/pypi/pysqlx-core/json"
for _ in range(3):
resp = httpx.get(uri)
if resp.is_success:
resp = urllib.request.urlopen(uri)
if resp.status == 200:
break
json: dict = resp.json()
return json["info"]["version"]
data: dict = json.loads(resp.read())
return data["info"]["version"]


version: str = get_version()
Expand All @@ -40,4 +43,4 @@ def get_version():
env_file = os.getenv('GITHUB_ENV')

with open(env_file, mode="a") as file:
file.write(f"\nPY_SQLX_VERSION=v{new_version}")
file.write(f"\nPY_SQLX_VERSION=v{new_version}")
23 changes: 14 additions & 9 deletions .github/release.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import httpx
import json
import urllib

import toml

with open("Cargo.toml", mode="r") as file:
Expand All @@ -8,24 +10,27 @@
def get_version():
uri = "https://pypi.org/pypi/pysqlx-core/json"
for _ in range(3):
resp = httpx.get(uri)
if resp.is_success:
resp = urllib.request.urlopen(uri)
if resp.status == 200:
break
json: dict = resp.json()
data: dict = json.loads(resp.read())

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

current_version = json["info"]["version"]
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


version: str = get_version()
file_version = toml.loads(text)["package"]["version"]

Expand Down Expand Up @@ -53,4 +58,4 @@ def get_version():
raise Exception("Could not update version, check the Cargo.toml file.")

with open("Cargo.toml", mode="w") as file:
file.write(new_text)
file.write(new_text)
6 changes: 3 additions & 3 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ jobs:
with:
components: llvm-tools

- run: pip install -U twine 'black>=22.3.0,<23' typing_extensions httpx toml
- run: pip install -U twine 'black>=22.3.0,<23' typing_extensions toml

- name: production - check package version
if: github.ref == 'refs/heads/main'
Expand Down Expand Up @@ -214,7 +214,7 @@ jobs:
with:
components: llvm-tools

- run: pip install -U twine 'black>=22.3.0,<23' typing_extensions httpx toml
- run: pip install -U twine 'black>=22.3.0,<23' typing_extensions toml

- name: production - check package version
if: github.ref == 'refs/heads/main'
Expand Down Expand Up @@ -260,7 +260,7 @@ jobs:
python-version: "3.10"

- name: install deps
run: pip install -U twine httpx toml
run: pip install -U twine toml

- name: production - check package version
if: github.ref == 'refs/heads/main'
Expand Down
2 changes: 1 addition & 1 deletion Cargo.lock

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

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "pysqlx-core"
version = "0.1.37"
version = "0.1.47"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

Expand Down

0 comments on commit dcf4daa

Please sign in to comment.