File tree Expand file tree Collapse file tree 1 file changed +9
-11
lines changed Expand file tree Collapse file tree 1 file changed +9
-11
lines changed Original file line number Diff line number Diff line change @@ -28,18 +28,16 @@ jobs:
2828
2929 - name : Delete existing release (if re-running)
3030 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-
3931 # 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
32+ RELEASE_ID=$(curl -s -H "Authorization: token $GITHUB_TOKEN" \
33+ "https://api.github.com/repos/${{ github.repository }}/releases/tags/${{ github.ref_name }}" \
34+ | jq -r '.id // empty')
35+
36+ if [ -n "$RELEASE_ID" ] && [ "$RELEASE_ID" != "null" ]; then
37+ echo "Release ${{ github.ref_name }} exists (ID: $RELEASE_ID), deleting to allow re-upload..."
38+ curl -X DELETE -H "Authorization: token $GITHUB_TOKEN" \
39+ "https://api.github.com/repos/${{ github.repository }}/releases/$RELEASE_ID" || true
40+ echo "Release deleted successfully"
4341 else
4442 echo "No existing release found for ${{ github.ref_name }}"
4543 fi
You can’t perform that action at this time.
0 commit comments