Skip to content

Commit ecfbca5

Browse files
committed
ci: replace softprops/action-gh-release with gh cli for robust asset overwrites
This swaps action-gh-release for built-in gh CLI commands that safely upload and replace assets to the existing release without attempting to re-finalize it and triggering duplicate draft issues.
1 parent 53e489a commit ecfbca5

1 file changed

Lines changed: 17 additions & 10 deletions

File tree

.github/workflows/ci.yml

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -138,11 +138,6 @@ jobs:
138138
runs-on: ubuntu-latest
139139
steps:
140140
- uses: actions/checkout@v6
141-
- name: Delete old release
142-
if: github.ref == 'refs/heads/master' || github.ref == 'refs/heads/main'
143-
env:
144-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
145-
run: gh release delete latest --cleanup-tag -y || true
146141

147142
- name: Update latest tag
148143
if: github.ref == 'refs/heads/master' || github.ref == 'refs/heads/main'
@@ -159,8 +154,20 @@ jobs:
159154
merge-multiple: true
160155

161156
- name: Release Artifacts
162-
uses: softprops/action-gh-release@v2
163-
with:
164-
tag_name: ${{ startsWith(github.ref, 'refs/tags/') && github.ref_name || 'latest' }}
165-
files: artifacts/*
166-
prerelease: ${{ !startsWith(github.ref, 'refs/tags/') }}
157+
env:
158+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
159+
run: |
160+
TAG_NAME="${{ startsWith(github.ref, 'refs/tags/') && github.ref_name || 'latest' }}"
161+
IS_PRERELEASE="${{ !startsWith(github.ref, 'refs/tags/') }}"
162+
163+
# Create release if it doesn't exist
164+
if ! gh release view "$TAG_NAME" >/dev/null 2>&1; then
165+
if [ "$IS_PRERELEASE" = "true" ]; then
166+
gh release create "$TAG_NAME" --title "$TAG_NAME" --prerelease
167+
else
168+
gh release create "$TAG_NAME" --title "$TAG_NAME"
169+
fi
170+
fi
171+
172+
# Upload files with clobber (overwrite)
173+
gh release upload "$TAG_NAME" artifacts/* --clobber

0 commit comments

Comments
 (0)