Skip to content

Commit 8bfc864

Browse files
author
Test User
committed
fix: delete existing release before GoReleaser to prevent asset conflicts
- Add step to delete existing release if it exists (for re-runs) - Prevents 'already_exists' errors when re-running workflows - Installs GitHub CLI if not available - Uses continue-on-error to not fail workflow if deletion fails
1 parent 372eb78 commit 8bfc864

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

.github/workflows/release.yml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,27 @@ jobs:
2626
with:
2727
go-version: '1.21'
2828

29+
- name: Delete existing release (if re-running)
30+
run: |
31+
# Install GitHub CLI if not available
32+
if ! command -v gh &> /dev/null; then
33+
echo "Installing GitHub CLI..."
34+
curl -fsSL https://cli.github.com/packages/githubcli-archive-keyring.gpg | sudo dd of=/usr/share/keyrings/githubcli-archive-keyring.gpg
35+
echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" | sudo tee /etc/apt/sources.list.d/github-cli.list > /dev/null
36+
sudo apt update && sudo apt install gh -y
37+
fi
38+
39+
# Check if release exists and delete it to allow re-upload
40+
if gh release view "${{ github.ref_name }}" &>/dev/null; then
41+
echo "Release ${{ github.ref_name }} exists, deleting to allow re-upload..."
42+
gh release delete "${{ github.ref_name }}" --yes || true
43+
else
44+
echo "No existing release found for ${{ github.ref_name }}"
45+
fi
46+
env:
47+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
48+
continue-on-error: true
49+
2950
- name: Run GoReleaser
3051
uses: goreleaser/goreleaser-action@v5
3152
with:

0 commit comments

Comments
 (0)