GoReleaser "git is currently in a dirty state" in CI
GoReleaser refuses to publish a real release when the git working tree has uncommitted changes, because the release would not correspond to a clean tagged commit. CI often dirties the tree by generating files before the build.
What this error means
GoReleaser stops with "git is currently in a dirty state" and lists the modified or untracked files that appeared during the job.
⨯ release failed after 0s
error=git is currently in a dirty state, please check in your pipeline what
can be changing the following files:
M go.sum
?? dist/Common causes
A build step modifies tracked files
Running go mod tidy, code generation, or formatting before GoReleaser changes files like go.sum, dirtying the tree.
Leftover artifacts are untracked
A previous dist/ or generated output left in the checkout appears as untracked files GoReleaser flags.
How to fix it
Keep the tree clean before release
- Commit or gitignore any files your pipeline generates (for example
dist/). - Run generation and
go mod tidybefore the tag, not in the release job. - Ensure the release runs against the exact tagged, committed state.
# .gitignore
dist/Use --snapshot for dirty test builds
For non-publishing CI builds where a dirty tree is acceptable, --snapshot skips the clean-tree requirement.
goreleaser release --snapshot --cleanHow to prevent it
- Gitignore build output like
dist/so it never dirties the tree. - Run codegen and
go mod tidybefore tagging, not during release. - Use
--snapshotfor test builds that do not need a clean tree.