Skip to content

Commit ae935ae

Browse files
committed
Add robust handling for release creation failures
- Add continue-on-error to release creation step to handle edge cases - Add explicit failure handling step to diagnose release creation issues - Provide clear warnings when releases already exist from previous runs - Handle orphaned tags (tags without corresponding releases) gracefully - Improve logging to help debug workflow issues
1 parent 0b205e4 commit ae935ae

1 file changed

Lines changed: 20 additions & 0 deletions

File tree

.github/workflows/npm-release-reusable.yml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,7 @@ jobs:
153153
git config user.email github-actions@github.com
154154
git tag -a "v${{ steps.get_version.outputs.version }}" -m "Release version ${{ steps.get_version.outputs.version }}"
155155
git push origin "v${{ steps.get_version.outputs.version }}"
156+
echo "Tag v${{ steps.get_version.outputs.version }} created and pushed successfully"
156157
157158
- name: Check if release exists
158159
id: check_release
@@ -171,6 +172,8 @@ jobs:
171172
- name: Create GitHub Release
172173
if: ${{ !inputs.dry-run && steps.check_release.outputs.exists == 'false' }}
173174
uses: actions/create-release@v1
175+
continue-on-error: true
176+
id: create_release
174177
env:
175178
GITHUB_TOKEN: ${{ secrets.GH_PAT }}
176179
with:
@@ -186,6 +189,23 @@ jobs:
186189
${{ inputs.docker-enabled && format('Docker image available at: `{0}/{1}:{2}`', secrets.ACR_URL, inputs.docker-image-name, steps.get_version.outputs.version) || 'No Docker image for this release' }}
187190
draft: false
188191
prerelease: false
192+
193+
- name: Handle release creation failure
194+
if: ${{ !inputs.dry-run && steps.check_release.outputs.exists == 'false' && steps.create_release.outcome == 'failure' }}
195+
run: |
196+
echo "::warning::Failed to create release for existing tag v${{ steps.get_version.outputs.version }}"
197+
echo "This might happen if:"
198+
echo " - The release was partially created in a previous run"
199+
echo " - There's a permission issue with the GitHub token"
200+
echo "Attempting to verify if release exists now..."
201+
if gh release view "v${{ steps.get_version.outputs.version }}" --repo ${{ inputs.repository }} >/dev/null 2>&1; then
202+
echo "::notice::Release exists for v${{ steps.get_version.outputs.version }} (may have been created in a previous run)"
203+
else
204+
echo "::error::Unable to create release for v${{ steps.get_version.outputs.version }}"
205+
exit 1
206+
fi
207+
env:
208+
GH_TOKEN: ${{ secrets.GH_PAT }}
189209

190210
- name: Update existing release
191211
if: ${{ !inputs.dry-run && steps.check_release.outputs.exists == 'true' && inputs.docker-enabled }}

0 commit comments

Comments
 (0)