Skip to content

Commit

Permalink
refactor: Do not use github API to get latest bun version to avoid be…
Browse files Browse the repository at this point in the history
…ing rate limited during CI builds
  • Loading branch information
ducdetronquito committed Aug 30, 2024
1 parent 735907b commit 9296905
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions src/make_wheels.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# pyright: basic
import json
import logging
import os
import sys
from argparse import ArgumentParser
from dataclasses import dataclass
from hashlib import sha256
from http.client import HTTPSConnection
from io import BytesIO
from pathlib import Path
from typing import TYPE_CHECKING, Any, Literal
Expand Down Expand Up @@ -310,12 +310,18 @@ def get_release_archive(


def get_latest_bun_version() -> str:
with request.urlopen(
"https://api.github.com/repos/oven-sh/bun/releases/latest"
) as response:
latest_tag = json.loads(response.read())["tag_name"]

latest_version = latest_tag.replace("bun-", "")
host = "github.com"
conn = HTTPSConnection(host)
try:
conn.request("GET", "/oven-sh/bun/releases/latest", headers={"Host": host})
response = conn.getresponse()
location_header = response.headers["location"]
finally:
conn.close()

latest_version = location_header.replace(
"https://github.com/oven-sh/bun/releases/tag/bun-", ""
)

return latest_version

Expand Down

0 comments on commit 9296905

Please sign in to comment.