Download Github Release with version tag - github

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 (i.e 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.

Related

Is there a link to GitHub for downloading a file from the repo tagged with the latest release?

The question Is there a link to GitHub for downloading a file in the latest release of a repository? gives you all you need to know in order to get to any files that are part of the latest release in a GitHub repo.
Along the same line, I wonder if you can link to a file IN THE REPOSITORY (not in the release) that was tagged with that latest release?
So instead of
https://github.com/USER/PROJECT/blob/COMMIT_HASH/myfile.json
I would like something along the lines of
https://github.com/USER/PROJECT/blob/releases/lates/myfile.json
The option is of course to do it in two steps, using the releases api and then get to it, but I wonder if there is a one-liner.
but I wonder if there is a one-liner.
No oneliner that I know of: you still need to get the SHA1 for the latest release, before being able to provide the file URL.
The problem is: the end result (file URL) will be a static one, and if there is a new release, you will have to compute the URL again.
So you might construe something based on the latest tag, like:
curl https://github.com/USER/PROJECT/blob/$(curl --silent "https://api.github.com/repos/$1/releases/latest" | jq -r .tag_name)/myfile.json

Download Directory from GitHub

Trying to download a folder from git.
I tried wget --no-parent -r http://WEBSITE.com/DIRECTORY and also without --no-parent - did not work. curl works fine with single files, I thought wget should get the folder - it does everything but that.
Tried many options as suggested Using wget to recursively fetch a directory with arbitrary files in it none worked
You should try:
git clone <SSH> or <HTTPS>
Maybe this can help you in a simple way:
DownGit
So, if you instead to use wget to download a directory, just try this.
It will pack your target directory into a .zip, so you can curlorwget it.
MinhasKamal/DownGit#github
In default, value of fileName and rootDirectory is set to the name of the downloading file or directory. If you do not want to add the directory itself in the zip, then set rootDirectory=false. Like: this link- https://minhaskamal.github.io/DownGit/#/home?url=https://github.com/MinhasKamal/DownGit/tree/master/res/images&rootDirectory=false, will download a file named images.zip; however the root directory- "images", will not be included in the zip.
If you want to download file- https://github.com/MinhasKamal/DownGit/blob/master/res/images/downgit.png with name- DownGitIcon.zip, then the link will be- https://minhaskamal.github.io/DownGit/#/home?url=https://github.com/MinhasKamal/DownGit/blob/master/res/images/downgit.png&fileName=DownGitIcon
By the way, I used to use SVN to download files/directory from a Git System by route the URL to its trunk. But it's very inconvenient.
A bit late but in case some one stumbles here later.
You can use following tools :
Download-Directory
DownGit
In both tools, you can just enter your url to direct download or create a download link.
For those who prefer GUI tools, there is another easy way to download a folder using code sandbox.
Navigate to the folder and replace github to githubbox in the URL. Then on code sandbox go to files pain on the left and hover the mouse over the down arrow, it will show a popup tooltip "Export to Zip". Just click on it to download the folder as a zip file.
reference: Download a single folder or directory from a BRANCH in GitHub repo

What do raw.githubusercontent.com URLs represent?

I want to learn how to use rawgit.com to serve other applications from github.com.
So we have a usual way to download and install homebrew on osx.
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
I can't find the install file on GitHub. Where is it?
The raw.githubusercontent.com domain is used to serve unprocessed versions of files stored in GitHub repositories. If you browse to a file on GitHub and then click the Raw link, that's where you'll go.
The URL in your question references the install file in the master branch of the Homebrew/install repository. The rest of that command just retrieves the file and runs ruby on its contents.
There are two ways of looking at github content, the "raw" way and the "Web page" way.
raw.githubusercontent.com returns the raw content of files stored in github, so they can be downloaded simply to your computer. For example, if the page represents a ruby install script, then you will get a ruby install script that your ruby installation will understand.
If you instead download the file using the github.com link, you will actually be downloading a web page with buttons and comments and which displays your wanted script in the middle -- it's what you want to give to your web browser to get a nice page to look at, but for the computer, it is not a script that can be executed or code that can be compiled, but a web page to be displayed. That web page has a button called Raw that sends you to the corresponding content on raw.githubusercontent.com.
To see the content of raw.githubusercontent.com/${user}/${repo}/${branch}/${path} in the usual github interface:
you replace raw.githubusercontent.com with plain github.com
AND you insert "blob" between the repo name and the branch name.
In this case, the user is "Homebrew", the repo is "install", the branch name is "master" (which is a very common branch name). You insert "blob" between "install" and "master", so
https://raw.githubusercontent.com/Homebrew/install/master/install
becomes
https://github.com/Homebrew/install/blob/master/install
This is the reverse of finding a file on Github and clicking the Raw link.
raw.githubusercontent.com/username/repo-name/branch-name/path
Replace username with the username of the user that created the repo.
Replace repo-name with the name of the repo.
Replace branch-name with the name of the branch.
Replace path with the path to the file.
To reverse to go to GitHub.com:
GitHub.com/username/repo-name/directory-path/blob/branch-name/filename

Golang tool for git pull?

I'm trying to make it easy for the not-too-technical to use my golang program as a command line application. I want them to be able to update the code easily too when I push changes to github. Is there a way to update a library using something like "go update github.com/user/repo" so they don't have to cd to the src directory and git pull themselves? Or at this point must I simply say "time to learn git"?
You can use:
go get -u import/path
The -u flag instructs get to use the network to update the named packages
and their dependencies. By default, get uses the network to check out
missing packages but does not use it to look for updates to existing packages.

Get latest revision number of a file from cvs repository

Is there a way to know the latest revision number of a file in cvs repository without checking out that file.
The exact problem is, suppose I know the name of a file which is in cvs repo. Let's call it file1.text.
So, is there any command or any way by which I can search repo for that file and get the latest revision number of that file?
You can use CVS log and give a revision as "starting point":
$ cvs log -r{REVISION}:: file1.text
The -r{REVISION}:: will only search for revisions after {REVISION} (can be a number or tag).
If you don't have a working copy, you can use rls cvs command. With -l argument, it will print the version of files.
$ cvs rls -l MyModule/path/to/the/file
You can use -r to specify a branch.
Here's the command to use:
cvs history -a -c -l module/file1.text
This will display the version and the date the file was last modified. This doesn't require the module or file checked out.