INNER CODE UNIT · Python

fetch_latest_release

CyrilPeng/Venera-Next · update_alt_store.py:42

def fetch_latest_release(repo_url):
    api_url = f"https://api.github.com/repos/{repo_url}/releases"
    headers = {
        "Accept": "application/vnd.github+json",
        "X-GitHub-Api-Version": "2022-11-28",
    }
    token = os.environ.get("GITHUB_TOKEN") or os.environ.get("GH_TOKEN")
    if token:
        headers["Authorization"] = f"Bearer {token}"
    request = Request(api_url, headers=headers)
    try:
        with urlopen(request, timeout=30) as response:
            releases = json.load(response)
        for release in releases:
            if not release.get("draft") and not release.get("prerelease"):
                return release
        raise RuntimeError("No published release found.")
    except (HTTPError, URLError, TimeoutError, json.JSONDecodeError) as e:

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…