Skip to content

fix: use --snapshot flag for GoReleaser dry-run mode#40

Merged
skyoo2003 merged 2 commits into
mainfrom
fix/goreleaser-workflow-dispatch
Apr 20, 2026
Merged

fix: use --snapshot flag for GoReleaser dry-run mode#40
skyoo2003 merged 2 commits into
mainfrom
fix/goreleaser-workflow-dispatch

Conversation

@skyoo2003
Copy link
Copy Markdown
Owner

Summary

  • Add --snapshot flag when running GoReleaser in dry-run mode via workflow_dispatch
  • Skip Docker Buildx setup and GHCR login during dry-run

Problem

When running the release workflow via workflow_dispatch in dry-run mode, GoReleaser failed with:

error=git tag v0.2.0 was not made against commit cd2e27b...

GoReleaser validates that the tag exists and points to the current commit. In dry-run mode (no actual tag pushed), this validation always fails.

Fix

Use --snapshot flag in dry-run mode, which tells GoReleaser to skip git state validation and build artifacts locally without publishing. Also gate Docker-related steps behind the dry-run check.

Test plan

  • Run workflow_dispatch with dry_run=true — should build without errors
  • Verify --snapshot produces artifacts in dist/ with snapshot version names
  • Confirm actual tag push still works (dry_run=false path unchanged)

When running via workflow_dispatch in dry-run mode, GoReleaser failed
because the tag does not exist on the commit. Use --snapshot to skip
git state validation and build without publishing. Also skip Docker
setup/login steps during dry-run.
@sourcery-ai
Copy link
Copy Markdown
Contributor

sourcery-ai Bot commented Apr 20, 2026

Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

Adjusts the GitHub Actions release workflow so that dry-run executions use GoReleaser’s snapshot mode and skip Docker-related steps, preventing git tag validation failures while avoiding unnecessary registry operations.

File-Level Changes

Change Details Files
Guard Docker setup and GHCR login so they only run for non-dry-run releases.
  • Removed unconditional Docker Buildx setup and GHCR login steps adjacent to Go toolchain setup.
  • Reintroduced Docker Buildx setup step with an if condition that checks github.event.inputs.dry_run != 'true'.
  • Reintroduced GHCR login step with the same dry-run guard, including existing registry, username, and password configuration.
.github/workflows/release.yml
Use GoReleaser snapshot mode in dry-run executions while keeping normal release behavior unchanged.
  • Replaced previous inline args expression that appended --skip-publish during dry_run with a formatted multi-line args block.
  • For dry_run=true, now invoke GoReleaser with: release --clean --snapshot --release-notes changes/.md.
  • For dry_run=false, keep existing behavior: release --clean --release-notes changes/.md, maintaining tag-based release semantics.
.github/workflows/release.yml

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@github-actions github-actions Bot added bug Something isn't working ci CI/CD workflows and scripts and removed bug Something isn't working labels Apr 20, 2026
@skyoo2003 skyoo2003 self-assigned this Apr 20, 2026
Copy link
Copy Markdown
Contributor

@sourcery-ai sourcery-ai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - I've found 1 issue

Prompt for AI Agents
Please address the comments from this code review:

## Individual Comments

### Comment 1
<location path=".github/workflows/release.yml" line_range="62-64" />
<code_context>
         version: "~> v2"
-        args: release --clean --release-notes changes/${{ steps.resolve_tag.outputs.tag }}.md ${{ github.event.inputs.dry_run == 'true' && '--skip-publish' || '' }}
+        args: >-
+          ${{ github.event.inputs.dry_run == 'true'
+              && format('release --clean --snapshot --release-notes changes/{0}.md', steps.resolve_tag.outputs.tag)
+              || format('release --clean --release-notes changes/{0}.md', steps.resolve_tag.outputs.tag) }}
       env:
         GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
</code_context>
<issue_to_address>
**suggestion:** Consider simplifying the conditional `args` expression to reduce duplication and improve readability.

Both ternary branches repeat `release --clean` and only differ by `--snapshot`. Consider computing the common base args once (e.g., via a job `env` or a prior step that sets an output) and conditionally appending `--snapshot` when `dry_run` is true. This keeps the flags in one place and reduces future maintenance risk.
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Comment thread .github/workflows/release.yml Outdated
…lve step

Move --snapshot flag computation into the resolve_tag step output
to eliminate duplicated args in the ternary expression.
@github-actions github-actions Bot added the bug Something isn't working label Apr 20, 2026
@skyoo2003 skyoo2003 merged commit 203c03f into main Apr 20, 2026
9 checks passed
@skyoo2003 skyoo2003 deleted the fix/goreleaser-workflow-dispatch branch April 20, 2026 17:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working ci CI/CD workflows and scripts

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant