Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Github API generated annotated tag not showing up in git describe

I am trying to write a script to automatically setup github releases using a custom CI trigger. I have a python script that uses pygithub to automatically create a tag and a release.

# roughly the following code:
repo.create_git_tag(...)
repo.create_git_ref(...)
repo.create_git_release(...)

After running the script, everything shows up in the GitHub web UI, after a git fetch origin && git tag -l, I can see the tags locally. But when I use git describe (even with --tags), it fails with fatal: No tags can describe '<head_commit_hash>'

Using git show-ref --tags, I get something like the following:

hash1 refs/tags/releases/1.0.0
hash2 refs/tags/releases/1.1.0
hash3 refs/tags/releases/1.1.1

Then git cat-file -p hash1 gives me:

object hash_of_commit_at_tag
type commit
tag releases/1.0.0
tagger ...

Release: 1.0.0

But if I create and push the tag myself using git tag -a releases/1.0.0 hash_of_commit -m "Release 1.0.0", the git describe gives me the last reachable tag from my current HEAD.

Question is, is GitHub api or pygithub doing anything special? Or am I missing an api call in pygithub?

like image 563
Tareq A. Siraj Avatar asked Aug 15 '26 10:08

Tareq A. Siraj


1 Answers

Apparently the GitHub API is creating un-annotated tags when you make a release.

The solution that works for me is to use git describe --tags

THis is from my repo with two tags created by making a release in the GitHub API

❯ git tag -l
v1.1.0
v1.2.0
❯ git describe
fatal: No annotated tags can describe '912268bd176bbda06983995894b46cf764b3e666'.
However, there were unannotated tags: try --tags.
❯ git describe --tags
v1.2.0
like image 135
Rian Sanderson Avatar answered Aug 17 '26 22:08

Rian Sanderson



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!