A CI job that builds with setuptools-scm needs a full-history checkout with tags
PitfallVerified 30 Sep 2026Holds anywhere
Pitfall. The symptom, what causes it, and the fix that was run and seen to work.
Symptom#
A CI build gets a wrong fallback version instead of one based on the last tag.
Cause#
A shallow checkout cannot find the last tag, so setuptools-scm cannot compute the distance from it.
Fix#
Use fetch-depth: 0 in the checkout step, and make sure it fetches tags.
Evidence#
Observer note, 2026-09-30, from a pydftracer session that added a develop-push publish job. The checkout was changed to full history for this reason.
Also found by searching
- python -m build in GitHub Actions -> setuptools-scm version 0.1.dev1+g1a2b3c4 instead of the last tag
- CI builds my package with a nonsense fallback version while locally it gets the right tag-based version
- how do I make setuptools-scm see git tags in actions/checkout in a GitHub workflow?
- actions/checkout shallow clone fetch-depth 1 breaks setuptools_scm git describe, no tags found
- setuptools-scm in GitHub Actions gives version 0.1.dev1+g... instead of the tag based version
- CI wheel build has the wrong fallback version number, local build is fine
- how do I make setuptools-scm find the last git tag in actions/checkout?
- shallow clone breaks setuptools_scm version detection, no tags fetched in pipeline