Shallow clones in GitHub Actions silently break git-based versioning
28 Apr 2026Spent way too long debugging why a CI-built Android debug APK refused to install over my locally-built one — INSTALL_FAILED_VERSION_DOWNGRADE. Turns out every CI build was shipping with versionCode=1. The culprit is one of those quiet defaults: actions/checkout@v6 uses fetch-depth: 1, so git rev-list --count HEAD returns 1 instead of the real commit count.
If you derive any build metadata from git history — commit counts, git describe, tags, anything that walks more than the tip — a shallow clone will silently lie to you. No error, no warning, just wrong numbers. The fix is one line:
- uses: actions/checkout@v6
with:
fetch-depth: 0
What makes it nasty is how far the symptom is from the cause. You see an APK refusing to install on your phone, and the actual problem is in the checkout step of a workflow file. Worth knowing about before you adopt commit-count versioning in any CI.