Skip to content

Commit 604a3d4

Browse files
committed
fix: Handle existing GitHub releases gracefully
- Replace deprecated actions/create-release with gh CLI - Check if release already exists before creating new one - Skip release creation if release already exists for tag - Prevents workflow failures on duplicate releases
1 parent e3c9d77 commit 604a3d4

1 file changed

Lines changed: 15 additions & 13 deletions

File tree

.github/workflows/version-bump.yml

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -145,14 +145,15 @@ jobs:
145145
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
146146

147147
- name: Create GitHub Release
148-
uses: actions/create-release@v1
149-
env:
150-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
151-
with:
152-
tag_name: v${{ env.new_version }}
153-
release_name: Release v${{ env.new_version }}
154-
body: |
155-
## Changes in this release
148+
run: |
149+
# Check if release already exists
150+
if gh release view "v${{ env.new_version }}" >/dev/null 2>&1; then
151+
echo "Release v${{ env.new_version }} already exists, skipping release creation"
152+
else
153+
echo "Creating new release v${{ env.new_version }}"
154+
gh release create "v${{ env.new_version }}" \
155+
--title "Release v${{ env.new_version }}" \
156+
--notes "## Changes in this release
156157
157158
This release was automatically created from PR #${{ github.event.pull_request.number }}
158159
@@ -165,12 +166,13 @@ jobs:
165166
### Published to crates.io
166167
${{ steps.check_version.outputs.version_exists == 'false' && 'This version has been published to [crates.io](https://crates.io/crates/gonfig) and is available for use in your projects.' || 'This version was already available on [crates.io](https://crates.io/crates/gonfig).' }}
167168
168-
```toml
169+
\`\`\`toml
169170
[dependencies]
170-
gonfig = "${{ env.new_version }}"
171-
```
172-
draft: false
173-
prerelease: false
171+
gonfig = \"${{ env.new_version }}\"
172+
\`\`\`"
173+
fi
174+
env:
175+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
174176

175177
- name: Update main branch with new version
176178
run: |

0 commit comments

Comments
 (0)