Skip to content

Commit

Permalink
support for downloading specific version of bins
Browse files Browse the repository at this point in the history
  • Loading branch information
crimera committed Nov 11, 2024
1 parent a3c7572 commit a8befac
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion download_bins.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from utils import download


def download_release_asset(repo: str, regex: str, out_dir: str, filename=None, include_prereleases: bool = False):
def download_release_asset(repo: str, regex: str, out_dir: str, filename=None, include_prereleases: bool = False, version = None):
url = f"https://api.github.com/repos/{repo}/releases"

response = requests.get(url)
Expand All @@ -15,6 +15,12 @@ def download_release_asset(repo: str, regex: str, out_dir: str, filename=None, i
if not releases:
raise Exception(f"No releases found for {repo}")

if version is not None:
releases = [r for r in releases if r["tag_name"] == version]

if len(releases) == 0:
raise Exception(f"No release found for version {version}")

latest_release = releases[0]

assets = latest_release["assets"]
Expand Down

0 comments on commit a8befac

Please # to comment.