fix: Race condition in GitHub actions release flow #1555
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fix GitHub Release Creation Error Handling in CI/CD Pipeline
Summary
This PR improves the error handling in the GitHub Actions release workflow by properly checking if a release already exists before attempting to create it. The previous implementation could fail when the release view command returned a non-zero exit code.
This ensures that during the GitHub release before matrix builds start, we get only one build trying to create a release.
Related Issues
Closes #1554
Files Changed
.github/workflows/release.yml: Modified the release creation logic to properly handle the case where a release tag already exists.Code Changes
.github/workflows/release.ymlThe release creation step has been refactored from a single line command to a proper conditional check:
Before:
gh release view ${{ env.latest_tag }} || gh release create ${{ env.latest_tag }} --title "Release ${{ env.latest_tag }}" --notes "Automated release for ${{ env.latest_tag }}"After:
Reason for Changes
The previous implementation using the
||operator could cause issues in the CI/CD pipeline whengh release viewreturned an error. This could happen when:By explicitly checking the exit code and redirecting output to
/dev/null, we ensure that:Impact of Changes
Test Plan
This change can be tested by:
Additional Notes
This is a defensive programming improvement that makes the CI/CD pipeline more resilient. The change follows shell scripting best practices by: