Skip to content

Commit 7e957a2

Browse files
authored
Clean up failed releases (#546)
1 parent 1c7a78f commit 7e957a2

File tree

1 file changed

+28
-2
lines changed

1 file changed

+28
-2
lines changed

.github/workflows/release.yml

+28-2
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ jobs:
3535
EXISTING_RELEASE: ${{ steps.release_flag.outputs.result }}
3636
steps:
3737
- name: Check for existing release tag
38-
uses: mukunku/tag-exists-action@v1.3.0
38+
uses: mukunku/tag-exists-action@v1.6.0
3939
id: check_tag
4040
with:
4141
tag: ${{ needs.get_version.outputs.ARK_VERSION }}
@@ -174,10 +174,36 @@ jobs:
174174
asset_name: ark-${{ needs.get_version.outputs.ARK_VERSION }}${{ env.DEBUG_FLAG }}-linux-arm64.zip
175175
asset_content_type: application/octet-stream
176176

177+
cleanup:
178+
name: Clean up Failed Releases
179+
if: ${{ failure() }}
180+
runs-on: ubuntu-latest
181+
needs: [upload_release_binaries, get_version]
182+
steps:
183+
# `gh` operates on the git repo
184+
- name: Checkout sources
185+
uses: actions/checkout@v4
186+
187+
- name: Check for existing release tag
188+
uses: mukunku/[email protected]
189+
id: check_tag
190+
with:
191+
tag: ${{ needs.get_version.outputs.ARK_VERSION }}
192+
193+
- name: Delete failed release if any
194+
if: steps.check_tag.outputs.exists == 'true'
195+
env:
196+
GH_TOKEN: ${{ github.token }}
197+
run: |
198+
TAG=${{ needs.get_version.outputs.ARK_VERSION }}
199+
gh release delete $TAG -y --cleanup-tag
200+
201+
# Keep this at the very end of the workflow tree and without any other
202+
# steps to ensure we get a Slack report when something failed
177203
status:
178204
if: ${{ failure() }}
179205
runs-on: ubuntu-latest
180-
needs: [build_macos, build_windows, get_version]
206+
needs: [cleanup, get_version]
181207
steps:
182208
- name: Notify slack if build fails
183209
uses: slackapi/[email protected]

0 commit comments

Comments
 (0)