Grab file based on file extension in Github through terminal

Viewed 33

I am trying to write a shell script for ArchLinux that installs all my packages.

I want to grab the latest .tar.gz file from https://github.com/GloriousEggroll/proton-ge-custom/releases/latest/

I found a lot of guides to download a specific file from GitHub using curl, but I could not find one for when the filename is unknown.
I will only have the extension since the filename changes with new releases.

Any help would be greatly appreciated as I am fairly new to doing things through the terminal.

1 Answers

You can get the version with:

curl -IkLs -o NUL -w %{url_effective} https://github.com/GloriousEggroll/proton-ge-custom/releases/latest \
|grep -o "[^/]*$"
6.21-GE-2

From there, you can curl the right URL.

I just tested:

vonc@vclp MINGW64 ~/test
$ curl -IkLs -o NUL -w %{url_effective} https://github.com/GloriousEggroll/proton-ge-custom/releases/latest \
     | grep -o "[^/]*$"\
     | xargs -I T \
       curl -kL https://github.com/GloriousEggroll/proton-ge-custom/releases/download/T/Proton-T.tar.gz \
       -o Proton-T.7z

  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   662  100   662    0     0   3256      0 --:--:-- --:--:-- --:--:--  3277
100  408M  100  408M    0     0  43.9M      0  0:00:09  0:00:09 --:--:-- 49.5M

vonc@vclp MINGW64 ~/test
$ ls -alrth
total 409M
drwxr-xr-x 1 vonc 197609    0 Dec  6 00:08 ..
drwxr-xr-x 1 vonc 197609    0 Dec 12 01:25 .
-rw-r--r-- 1 vonc 197609 409M Dec 12 01:25 Proton-6.21-GE-2.7z

You can use that one-liner in your own script.

Related