Skip to content

Commit 203c03f

Browse files
authored
fix: use --snapshot flag for GoReleaser dry-run mode (#40)
* 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. * refactor: simplify GoReleaser args by computing snapshot flag in resolve step Move --snapshot flag computation into the resolve_tag step output to eliminate duplicated args in the ternary expression.
1 parent cd2e27b commit 203c03f

1 file changed

Lines changed: 16 additions & 10 deletions

File tree

.github/workflows/release.yml

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -33,30 +33,36 @@ 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
46-
run: echo "tag=${{ github.event.inputs.tag || github.ref_name }}" >> "$GITHUB_OUTPUT"
38+
run: |
39+
echo "tag=${{ github.event.inputs.tag || github.ref_name }}" >> "$GITHUB_OUTPUT"
40+
if [[ "${{ github.event.inputs.dry_run }}" == "true" ]]; then
41+
echo "extra_flags=--snapshot" >> "$GITHUB_OUTPUT"
42+
fi
4743
- name: Verify changie release notes exist
4844
run: |
4945
if [ ! -f "changes/${{ steps.resolve_tag.outputs.tag }}.md" ]; then
5046
echo "::error::Changie fragment changes/${{ steps.resolve_tag.outputs.tag }}.md not found."
5147
echo "::error::Run 'changie batch ${{ steps.resolve_tag.outputs.tag }}' and 'changie merge' before pushing the tag."
5248
exit 1
5349
fi
50+
- name: Set up Docker Buildx
51+
if: ${{ github.event.inputs.dry_run != 'true' }}
52+
uses: docker/setup-buildx-action@4d04d5d9486b7bd6fa91e7baf45bbb4f8b9deedd # v4
53+
- name: Login to GitHub Container Registry
54+
if: ${{ github.event.inputs.dry_run != 'true' }}
55+
uses: docker/login-action@4907a6ddec9925e35a0a9e82d7399ccc52663121 # v4
56+
with:
57+
registry: ghcr.io
58+
username: ${{ github.actor }}
59+
password: ${{ secrets.GITHUB_TOKEN }}
5460
- name: Execute GoReleaser
5561
uses: goreleaser/goreleaser-action@ec59f474b9834571250b370d4735c50f8e2d1e29 # goreleaser-action v7
5662
with:
5763
distribution: goreleaser
5864
version: "~> v2"
59-
args: release --clean --release-notes changes/${{ steps.resolve_tag.outputs.tag }}.md ${{ github.event.inputs.dry_run == 'true' && '--skip-publish' || '' }}
65+
args: release --clean ${{ steps.resolve_tag.outputs.extra_flags }} --release-notes changes/${{ steps.resolve_tag.outputs.tag }}.md
6066
env:
6167
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
6268
- name: Upload assets

0 commit comments

Comments
 (0)