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?
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With