Help
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Copilot Lvl 3
Message 1 of 6

Is there any api to retrieve tags for a specific commit_sha ?

Hi,

I am looking for an api which can return the tags associated to a specific commit. I searched for but didn't find any.

 

 

 

One solution I see is to get all tags in repository and then filter it. What is the suggested way to achieve this?

 

Thanks,

Akbar

5 Replies
Highlighted
Community Manager
Message 2 of 6

Re: Is there any api to retrieve tags for a specific commit_sha ?

Hi @mdmdakbar,

 

Thanks for being here! You can extract the list of tags for your repo, then the specific tag (release tag name) you are interested in & the previous tag, and get all commits between these 2 ie:

 

curl -X "GET" "https://api.github.com/repos/:owner/:repo/compare/:tag_1...:tag_2" \
     -H "Authorization: token YOUR_GITHUB_ACCESS_TOKEN"

I hope this helps!

Andrea


My very best,
Andrea

Mark helpful posts with Accept as Solution to help other users locate important info. Don't forget to give Kudos for great content!

Highlighted
Copilot Lvl 3
Message 3 of 6

Re: Is there any api to retrieve tags for a specific commit_sha ?

Sorry, this is not what I wanted. May be I was not clear.

 

I want an api which takes commit_sha as input parameter and returns me all the tags for that commit_sha.

Hope I am clear this time

Highlighted
Copilot Lvl 2
Message 4 of 6

Re: Is there any api to retrieve tags for a specific commit_sha ?

@AndreaGriffiths11 as per @mdmdakbar  comment do you know any way we can get tags for a commit?

Highlighted
Ground Controller Lvl 1
Message 5 of 6

Re: Is there any api to retrieve tags for a specific commit_sha ?

Is this solution still a valid solution in v3? I tried that in postman and wasn't able to get a response :( 

 

Since my tags are like "app/testing-123-123-123", my requst in postman looks something like this:

https://api.github.com/v3/repos/UrbanCompass/uc-frontend/compare/:tag_1...:tag_2, where :tag_1...:tag_2 is a path variable equal to the value "app/testing-123-123-123...app/testing-123-123-678"

Highlighted
Copilot Lvl 3
Message 6 of 6

Re: Is there any api to retrieve tags for a specific commit_sha ?

I found this confusing/misleading as well. After releasing an action yesterday and tagging the first version as 1.0.0, I was expecting to be able to use v1 to point to my 1.0.0 version, but was instead getting errors that the action could not be found.

 

I had read here that in order to use an action, you just need to specify the major version to recieve critical updates and I thought this meant it happens automatically. However I was wrong.

 

According to this page, what they expect of the action author is that each time a minor version is released, he/she should change the tag corresponding to the major version of that release to point to the new tag, which means that the users of the action will not need to follow minor releases to stay up-to-date.

 

Move the major version tag (v1, v2, etc.) to point to the Git ref of the current release. For more information, see "Git basics - tagging."

 

In light of this, today I created the actions-tagger action which does this automatically for actions authors who may want to have their actions version automatically follow this versioning scheme.