1

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.

Fontanka16
  • 1,161
  • 1
  • 9
  • 37

1 Answers1

1

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
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250