Where are my git tags?

My Android CircleCi project needs access to existing git tags to apply the correct version number to build artifacts. But it cannot find them, even after I added git fetch --tags to circle.yml.

Here’s an ssh transcript from the build machine showing the problem

$ git rev-parse HEAD
0038d1deef46f18e89ec8a0d7449eb0a559dde00
$ git rev-parse --verify 2.0.0-alpha 
dd5b8c764a0c819bea7fb6d1f03483ea67f3a136
$ git describe --tags
fatal: No tags can describe '0038d1deef46f18e89ec8a0d7449eb0a559dde00'.
Try --always, or create some tags.

In the same SSH session, if I clone from github to another subfolder, it works fine and git describe --tags finds the tag, no problem.

This was broken because CircleCi does a “shallow” fetch by default. To make sure I get the full git history including any tags that might be necessary, I had to add the following command to my circle.yml:

test:
  override:
    - git fetch --unshallow
    (etc...)

If you’re using lightweight tags you may also need a git fetch --tags line.

1 Like

Im in a similar position, where my python package depends on git tags for version information, and had trouble getting CircleCI to deploy correctly to PyPI. Adding this to my circle.yml fixed it:

checkout:
  post:
    - git fetch --tags && git tag