Skip to content

Instantly share code, notes, and snippets.

@mnewt
Created May 20, 2017 21:33
Show Gist options
  • Save mnewt/b076b6fa05f80eb7ac64684fc943ee7d to your computer and use it in GitHub Desktop.
Save mnewt/b076b6fa05f80eb7ac64684fc943ee7d to your computer and use it in GitHub Desktop.

Revisions

  1. mnewt created this gist May 20, 2017.
    12 changes: 12 additions & 0 deletions gh-download-latest
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,12 @@
    #!/bin/sh
    # Download a github project's latest release
    # $1: username/repo
    # $2: regex to match download file
    # example: ./gh-download-latest atom/atom gz

    repo=$1
    regex=${2:-gz}

    wget -qO- https://api.github.com/repos/$repo/releases/latest | \
    awk -v regex="$regex" -F '"' '/browser_download_url/ && match($4, regex) { print $4 }' | \
    xargs wget