semantic-release shallow clone / fetch-depth 0 history missing in CI
actions/checkout defaults to a shallow clone (fetch-depth 1) with no tags. semantic-release reads the full commit history and tags to find the last release and the commits since. Without them it can compute the wrong version or find no prior release at all.
What this error means
semantic-release reports it found no previous release, releases 1.0.0 on an established package, or analyzes only the latest commit because history and tags are missing.
[semantic-release] No git tag version found on branch main
[semantic-release] There is no previous release, the next release version is 1.0.0Common causes
The default shallow checkout omits history and tags
With fetch-depth 1, only the latest commit is present and tags are not fetched, so semantic-release cannot see prior releases.
Tags were not fetched even with full depth
Some setups fetch depth but skip tags; semantic-release then misidentifies the last released version.
How to fix it
Fetch the full history in checkout
- Set
fetch-depth: 0so all commits and tags are available. - Keep the default persist-credentials so the push can authenticate.
- Re-run so semantic-release sees the real last release.
- uses: actions/checkout@v4
with:
fetch-depth: 0Fetch tags if you customized the checkout
If you fetch manually, make sure tags come along so the last version is detected.
git fetch --prune --unshallow --tagsHow to prevent it
- Always set fetch-depth: 0 for semantic-release jobs.
- Ensure tags are fetched, not just commit depth.
- Verify the detected last release in the log after config changes.