0

I'm trying to find a way to download the latest released .deb file from a Github releases page, for example: https://github.com/grafviktor/goto/releases.

the solution would first try to curl the page and then find the latest released .deb and then download it, I can't wrap my head around the complexity of this so there maybe another way too but I prefer to do it with curl and wget,I found some similar posts but couldn't put a command together that would do this for me, so any help is appreciated.

Thank you everyone.

1 Answer 1

0

You can use the GitHub API for this; to retrieve the URL for the amd64 .deb file published in the latest release:

curl -s https://api.github.com/repos/grafviktor/goto/releases/latest | \
jq -r '(.assets[].browser_download_url | select(. | contains("_amd64.deb")))'

The curl command retrieves the JSON document describing the latest release, and does so with no progress output (-s). This JSON document is piped into jq, extracting the browser download URL for each asset, and filtering those which contain _amd64.deb. The result is output as raw text (-r), with no quotes.

3
  • Thanks for the explanation, this is a great solution but it would be interesting to be able to do this without GitHub API using pure curl and wget or similar tools to parse and extract the latest deb and then download it.
    – Ilgar
    Commented May 15 at 8:41
  • Could you clarify what bothers you with using the GitHub API? It’s designed exactly for this sort of usage; the web frontend isn’t, and can’t be parsed reliably. For one thing, on projects with lots of assets or lots of releases, it doesn’t necessarily include the assets you want on the initial load, and requires interpreting JavaScript to download the missing information. Commented May 15 at 9:40
  • Nothing, it's a reliable way to do this and I understand that, I'm just curious to see what could be done to download this in case of not having an API, maybe consider it as a challenge.
    – Ilgar
    Commented May 15 at 9:48

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .