Run, Developer, Run!

How to download latest release from Github

Sometimes you might want to download latest release of binary from Github repo using script. You can do this using API, but lets assume that on some enviroments you have only basic tools, and no jq to extract values from JSon.

  1. Git hub has built in redirect, i.e. which redirect to page dedicated to latest release
  2. We can get redirect url with curl, i.e. curl -Ls -o /dev/null -w "%{url_effective}" will get us
  3. Now we can extract version by using basename, i.e. basename will return 0.15.9
  4. Using this version we can construct download url.

For example script that downloads and installs latest version of fzf

    export FZF_VERSION=$(curl -Ls -o /dev/null -w "%{url_effective}" | xargs basename)
    curl -L$FZF_VERSION/fzf-$FZF_VERSION-linux_amd64.tgz | tar -xz -C /tmp/
    sudo mv /tmp/fzf-$FZF_VERSION-linux_amd64 /usr/bin/fzf



Me on Twitter, Mastodon and Github

We have RSS!

© 20xx

Hosted on Cloudflare Pages, which is awesome!