Link releases with commit

Hi I am trying to find all the merge commits that were done on our master branch. I am correlating this to our release tags that we generate. I cannot seem to find the link between the release object and the commit object. I am using the following apis to get the two data types

api/v3/repos/{repo}/releases api/v3/repos/{repo}/commits

Any suggestions on what I am doing wrong? If I go to the UI and click on the release tag it shows the commit sha (short version) on the UI so I assume it is possibly to link the two.

Hello @mattgolding and welcome to the community.

GitHub Releases are always tied to git tags rather than specific commits, even though tags themselves refer to specific commits. So, in order to find the commit that a release refers to, you have to first find the tag the release is linked to and then find the commit the tag is linked to. For example:

$ http

----- SNIP ----
    "created_at": "2020-10-02T20:50:18Z",
    "draft": false,
    "html_url": "",
    "id": 32111440,
    "name": "v1.0.2",
    "node_id": "MDc6UmVsZWFzZTMyMTExNDQw",
    "prerelease": false,
    "published_at": "2020-10-02T20:49:51Z",
    "tag_name": "v1.0.2",
----- SNIP -----

Notice that the tag_name is v1.0.2, then we can issue:

$ http ""

    "node_id": "MDM6UmVmMjI1OTYzODk2OnJlZnMvdGFncy92MS4wLjI=",
    "object": {
        "sha": "de87217698e438ed47d05d089c0fb4893f765872",
        "type": "commit",
        "url": ""
    "ref": "refs/tags/v1.0.2",
    "url": ""

And object.sha is the value that you’re looking for.

I hope that helps!

Thanks @lee-dohm exactly what I was after.

One more on the same topic. Is there a way to get the commits that happened between 2 release tags ? Or would I have to get the commit against each release as you showed above and then you those 2 commit sha’s to see whats in between those ?

Yes, you can by using the compare API call. For example:

http ""

I hope that helps!

Thanks @lee-dohm will give that a try. I thought that only compared between two commit ids but your example is using the release tags so will give that a try.


1 Like