Skip to content

Commit cde1d8b

Browse files
committed
ci(release): upload into an existing release instead of creating a second one
1 parent 89ab3e1 commit cde1d8b

1 file changed

Lines changed: 10 additions & 3 deletions

File tree

.github/workflows/release.yaml

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -177,16 +177,23 @@ jobs:
177177
run: cd archives && sha256sum * > checksums.txt && cat checksums.txt
178178

179179
# Draft, like goreleaser's `release.draft: true`; a prerelease suffix on
180-
# the tag marks it prerelease, like `prerelease: auto`.
180+
# the tag marks it prerelease, like `prerelease: auto`. `gh release
181+
# create` is not idempotent: on a tag that already has a release it
182+
# creates a second, untagged one and exits 0, so upload into the
183+
# existing release instead.
181184
- name: Create draft release
182185
env:
183186
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
184187
GH_REPO: ${{ github.repository }}
185188
run: |
186189
prerelease=()
187190
case "$GITHUB_REF_NAME" in *-*) prerelease=(--prerelease) ;; esac
188-
gh release create "$GITHUB_REF_NAME" --draft --generate-notes --title "$GITHUB_REF_NAME" \
189-
"${prerelease[@]}" archives/*
191+
if gh release view "$GITHUB_REF_NAME" >/dev/null 2>&1; then
192+
gh release upload "$GITHUB_REF_NAME" --clobber archives/*
193+
else
194+
gh release create "$GITHUB_REF_NAME" --draft --generate-notes --title "$GITHUB_REF_NAME" \
195+
"${prerelease[@]}" archives/*
196+
fi
190197
191198
# Build + push multi-arch Docker images on Linux (where the Docker daemon
192199
# lives), reusing the cgo linux binaries from the linux build jobs.

0 commit comments

Comments
 (0)