Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Bash script to download latest release from GitHub

Looking for a simple way to download a .zip from a latest GitHub release. There are other similar questions, but I havent been able to get them to work. :(

Trying to pull latest release from https://github.com/CTCaer/hekate

Currently ive got:

#!/bin/bash
curl -s https://api.github.com/repos/CTCaer/hekate/releases/latest | jq -r ".assets[] | select(.name | test(\"hekate_ctcaer\")) | .browser_download_url"

trying to fetch the url of the latest .zip and only grab the "hekate_ctcaer_X.X.X_Nyx_X.X.X.zip"

I saw someone trying to achieve this with 'Xidel', so im open to trying that if someone knows the syntax to grab a specific file from the GitHub api.

As I understand it (?), the Github API spits out an array for the release 'assets', so im trying to specify an item in this array that matches "hekate_ctcaer", and download the specified file.

like image 708
Fraxalotl Avatar asked Nov 28 '25 18:11

Fraxalotl


1 Answers

Github is also a compatible git repo. I provide a new train of thought.

  • use git ls-remote to fetch last release tag.
git -c 'versionsort.suffix=-' ls-remote --tags --sort='v:refname' http://github.com/CTCaer/hekate.git
| tail --lines=1
| cut --delimiter='/' --fields=3

Here this examples outputs v5.8.0

  • then clone remote repo
git clone --branch v5.8.0 http://github.com/CTCaer/hekate.git
  • zip repos to zipped file.
zip hekate.zip -r hekate/
like image 92
mariolu Avatar answered Nov 30 '25 10:11

mariolu



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!