Check if release exists before creating a new one#49
Check if release exists before creating a new one#49RaoulSchaffranek merged 3 commits intomasterfrom
Conversation
There was a problem hiding this comment.
If you want to create a release before doing all the other work, I'd suggest you to use draft releases like we do with K.
The structure is as follows:
draft-release:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Create Draft Release
id: create_release
uses: softprops/action-gh-release@v1
with:
draft: true
tag_name: v${{ github.run_number }} # Example tag name
name: Draft Release ${{ github.run_number }}
body: |
This is a draft release.
Details will be added once testing is complete.
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
build-and-test:
needs: draft-release # Ensure this job runs after the draft release is created
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
# Add your build and test steps here
- name: Upload assets to draft release
uses: actions/upload-release-asset@v1
with:
upload_url: ${{ needs.draft-release.outputs.upload_url }}
asset_path: ./path/to/your/asset.zip
asset_name: asset.zip
asset_content_type: application/zip
publish-or-delete-release:
needs: build-and-test
if: success() # Run only if the 'build-and-test' job was successful
runs-on: ubuntu-latest
steps:
- name: Publish Release
id: publish_release
uses: ncipollo/release-action@v1
with:
# Use the tag from the draft release step
tag: v${{ github.run_number }}
# The release is already created, so we just need to update it
token: ${{ secrets.GITHUB_TOKEN }}
delete-draft-on-failure:
needs: build-and-test
if: failure() # Run only if the 'build-and-test' job failed
runs-on: ubuntu-latest
steps:
- name: Delete Draft Release
uses: author/action-rollback@v1 # Example action to delete release
with:
tag: v${{ github.run_number }} # Specify the tag of the draft release to delete
token: ${{ secrets.GITHUB_TOKEN }}There was a problem hiding this comment.
The primary difference I see is this cleans up the draft release on failure, and if a new release occurs before yours is manually fixed the release becomes unrelated to actual release artifacts. If the draft is not cleaned it's also not official in the GH pipeline and isn't tagged.
The bare minimum I'd suggest to delete the release on failure.
There was a problem hiding this comment.
In the case of simbolik-vscode we run the build step before the release step. If the build step fails, no release is uploaded; hence, cleaning up is unnecessary. Or am I missing something?
This PR checks if a GitHub release already exists before creating a new release.
This is needed to avoid the following deadlock:
This happened just now: https://github.com/runtimeverification/simbolik-vscode/actions/runs/16137751602