Skip to content

Commit 29bc5a5

Browse files
committed
fix: use --snapshot flag for GoReleaser dry-run mode
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.
1 parent cd2e27b commit 29bc5a5

1 file changed

Lines changed: 14 additions & 9 deletions

File tree

.github/workflows/release.yml

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -33,14 +33,6 @@ jobs:
3333
with:
3434
go-version-file: go.mod
3535
cache-dependency-path: go.sum
36-
- name: Set up Docker Buildx
37-
uses: docker/setup-buildx-action@4d04d5d9486b7bd6fa91e7baf45bbb4f8b9deedd # v4
38-
- name: Login to GitHub Container Registry
39-
uses: docker/login-action@4907a6ddec9925e35a0a9e82d7399ccc52663121 # v4
40-
with:
41-
registry: ghcr.io
42-
username: ${{ github.actor }}
43-
password: ${{ secrets.GITHUB_TOKEN }}
4436
- name: Resolve tag
4537
id: resolve_tag
4638
run: echo "tag=${{ github.event.inputs.tag || github.ref_name }}" >> "$GITHUB_OUTPUT"
@@ -51,12 +43,25 @@ jobs:
5143
echo "::error::Run 'changie batch ${{ steps.resolve_tag.outputs.tag }}' and 'changie merge' before pushing the tag."
5244
exit 1
5345
fi
46+
- name: Set up Docker Buildx
47+
if: ${{ github.event.inputs.dry_run != 'true' }}
48+
uses: docker/setup-buildx-action@4d04d5d9486b7bd6fa91e7baf45bbb4f8b9deedd # v4
49+
- name: Login to GitHub Container Registry
50+
if: ${{ github.event.inputs.dry_run != 'true' }}
51+
uses: docker/login-action@4907a6ddec9925e35a0a9e82d7399ccc52663121 # v4
52+
with:
53+
registry: ghcr.io
54+
username: ${{ github.actor }}
55+
password: ${{ secrets.GITHUB_TOKEN }}
5456
- name: Execute GoReleaser
5557
uses: goreleaser/goreleaser-action@ec59f474b9834571250b370d4735c50f8e2d1e29 # goreleaser-action v7
5658
with:
5759
distribution: goreleaser
5860
version: "~> v2"
59-
args: release --clean --release-notes changes/${{ steps.resolve_tag.outputs.tag }}.md ${{ github.event.inputs.dry_run == 'true' && '--skip-publish' || '' }}
61+
args: >-
62+
${{ github.event.inputs.dry_run == 'true'
63+
&& format('release --clean --snapshot --release-notes changes/{0}.md', steps.resolve_tag.outputs.tag)
64+
|| format('release --clean --release-notes changes/{0}.md', steps.resolve_tag.outputs.tag) }}
6065
env:
6166
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
6267
- name: Upload assets

0 commit comments

Comments
 (0)