Skip to content

Fix GoReleaser dirty state failure in release workflow #27

@SebastienMelki

Description

@SebastienMelki

Bug Description

The GitHub Actions release workflow is failing because GoReleaser detects a dirty git state. The test coverage generation step creates/modifies coverage report files that are not properly cleaned up before the release step.

Error Details

git is in a dirty state
Please check in your pipeline what can be changing the following files:
 M coverage/coverage.html
 M coverage/coverage.json

Steps to Reproduce

  1. Create a git tag (e.g., v0.0.2)
  2. Push the tag to trigger the release workflow
  3. Workflow fails at the GoReleaser step due to dirty git state

Root Cause

The ./scripts/run_tests.sh script generates coverage reports in the coverage/ directory:

  • coverage/coverage.html
  • coverage/coverage.json
  • coverage/coverage-badge.svg
  • coverage/coverage.out

These files are being created/modified during the test step but aren't cleaned up or ignored before GoReleaser runs.

Proposed Solutions

Option 1: Add coverage/ to .gitignore

Add the coverage directory to .gitignore to prevent it from being tracked by git.

Option 2: Clean coverage files in workflow

Modify the GitHub Actions workflow to clean up coverage files after tests but before GoReleaser runs:

- name: Clean up coverage files
  run: rm -rf coverage/

Option 3: Use GoReleaser skip-validate

Add --skip-validate flag to GoReleaser command (not recommended as it bypasses important checks).

Recommended Fix

Implement Option 1 (add to .gitignore) combined with Option 2 (cleanup in workflow) for robustness.

Files Affected

  • .github/workflows/release.yml
  • .gitignore (potentially)
  • scripts/run_tests.sh (potentially for cleanup logic)

Environment

  • GitHub Actions runner: ubuntu-24.04
  • GoReleaser version: v2.11.2
  • Go version: 1.24.6

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions