简体   繁体   中英

Download Github Release with version tag

I have a Github release and I want to download the latest assests with the version tag.

I want to save the.exe file with version include but this will prevent me from downloading the latest release with a single same link every time.

发布详情

I want to download the latest released Outdated-Snake.Setup.exe with the tag name (ie Outdated-Snake.Setup.v2.0.1.exe something like this)

Can I do it with editing the link somehow or do I have to change the.exe file name somehow? What should I do?

You can't do this when you're downloading via the web interface unless you use your browser's Save As functionality.

However, if you're downloading with curl from the command line, you can use the -o option to specify a file name that you'd like to use to save the file. For example, if I wanted to download the latest Git LFS Windows installer to foo.exe , I could do this:

$ curl -L -o foo.exe \
  https://github.com/git-lfs/git-lfs/releases/download/v2.13.3/git-lfs-windows-v2.13.3.exe

You can also write a small shell function to extract the tag from the URL (say, with sed's s command) and then use that to name the file. For example, with the Git LFS file I mentioned above, you could do something like this:

download () {
    url="$1"
    version=$(echo "$1" | sed -e 's!^.*/\(v[0-9]*\.[0-9\]*\.[0-9]*\)/.*$!\1!')
    curl -L -o foo-$version.exe "$url"
}

Since you haven't linked to the repository from which you're trying to download, I can't provide an example that will work with that specific repository, but you can make appropriate adjustments to suit your situation.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM