naor
naor

Reputation: 3650

How to list the releases of a repository?

Can the GitHub API return a list of repository's releases, along with the date each release was created?

The "releases" API is acting unexpectedly, e.g. 0 releases for rails:

>> curl https://api.github.com/repos/rails/rails/releases
[

]

Additionally, is there a way to know if a release is alpha, beta or stable?

Upvotes: 21

Views: 25391

Answers (4)

poy
poy

Reputation: 10507

This question is old, however Google still lead me here and the answers are dated. So for any others that find themselves here:

GitHub has sense added a releases endpoint: https://docs.github.com/en/rest/reference/releases

An example of getting one (via curl):

curl https://api.github.com/repos/rails/rails/releases

Upvotes: 17

Sam Bacha
Sam Bacha

Reputation: 119

Releases on GitHub can have assets attached to them. You can link to each of them, however, you can't link to the assets of the latest release.

You have two options:

Leverage a shell command and pipe the results to parse the response from github: example:

curl https://api.github.com/repos/direnv/direnv/releases/latest \
| jq -r '.assets[] | select(.browser_download_url | contains("linux-amd64")) | .browser_download_url'

response

https://github.com/direnv/direnv/releases/download/v2.28.0/direnv.linux-amd64

Option 2: Use a 3rd Party service like gitreleases.dev

With a Git Releases link, you can skip updating your README or public website with a new download link whenever a new release has been done. Instead, it will always point to the right location.

https://gitreleases.dev/

Upvotes: 1

kristenmills
kristenmills

Reputation: 1287

I don't think you can specifically do releases. But you can get tags.

curl https://api.github.com/repos/rails/rails/tags

Source: http://developer.github.com/v3/repos/#list-tags

Edit:

They released the releases API today.

http://developer.github.com/v3/repos/releases/

Upvotes: 23

Ian Stapleton Cordasco
Ian Stapleton Cordasco

Reputation: 28717

There is no /releases endpoint for repositories (yet?). The only way to vaguely get anything like that is to use @kristenmills answer of listing tags. That's how releases are currently generated on GitHub's site and that's exactly how you can determine what has been released.

Upvotes: 0

Related Questions