CI: Support cancelling, update actions & prevent draft releases

Allow the workflow to be cancelled without running all remaining jobs.
On invocation of the workflow, cancel concurrent runs of older commits
automatically.

Replace unmaintained release action with recommended alternative.

After much testing, I found that the problem of releases
being created as draft releases can be traced to a
consistency issue/race condition on GitHub's side.
Prevent this by inserting a generous delay between deleting and
re-creating the edge release.
pull/1015/head
Maximilian Federle 2021-04-08 16:24:53 +02:00 committed by phkahler
parent af5fbf6364
commit f4ad82055e
1 changed files with 31 additions and 13 deletions

View File

@ -9,9 +9,20 @@ on:
- created - created
jobs: jobs:
cancel_previous_runs:
runs-on: ubuntu-latest
name: Cancel Previous Runs
if: github.event_name == 'push'
steps:
- uses: styfle/cancel-workflow-action@0.8.0
with:
access_token: ${{ github.token }}
test_ubuntu: test_ubuntu:
needs: [cancel_previous_runs]
runs-on: ubuntu-18.04 runs-on: ubuntu-18.04
name: Test Ubuntu name: Test Ubuntu
if: "!cancelled()"
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v2
- name: Install Dependencies - name: Install Dependencies
@ -20,8 +31,10 @@ jobs:
run: .github/scripts/build-ubuntu.sh run: .github/scripts/build-ubuntu.sh
test_windows: test_windows:
needs: [cancel_previous_runs]
runs-on: windows-2019 runs-on: windows-2019
name: Test Windows name: Test Windows
if: "!cancelled()"
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v2
- name: Install Dependencies - name: Install Dependencies
@ -32,8 +45,10 @@ jobs:
shell: bash shell: bash
test_macos: test_macos:
needs: [cancel_previous_runs]
runs-on: macos-10.15 runs-on: macos-10.15
name: Test macOS name: Test macOS
if: "!cancelled()"
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v2
- name: Install Dependencies - name: Install Dependencies
@ -164,26 +179,29 @@ jobs:
update_edge_release: update_edge_release:
name: Update Edge Release name: Update Edge Release
needs: [build_release_windows, build_release_windows_openmp, build_release_macos] needs: [build_release_windows, build_release_windows_openmp, build_release_macos]
if: always() && github.event_name == 'push' if: github.event_name == 'push' && !cancelled()
runs-on: ubuntu-latest runs-on: ubuntu-latest
outputs: outputs:
upload_url: ${{ steps.create_release.outputs.upload_url }} upload_url: ${{ steps.create_release.outputs.upload_url }}
steps: steps:
- name: Delete Old Edge Release - name: Delete Old Edge Release
uses: dev-drprasad/delete-tag-and-release@v0.1.2 uses: dev-drprasad/delete-tag-and-release@v0.2.0
with: with:
delete_release: true delete_release: true
tag_name: edge tag_name: edge
env: env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Wait
shell: bash
run: sleep 60
- name: Create New Edge Release - name: Create New Edge Release
id: create_release id: create_release
uses: actions/create-release@v1 uses: softprops/action-gh-release@35d938cf01f60fbe522917c81be1e892074f6ad6
env: env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with: with:
tag_name: edge tag_name: edge
release_name: Edge name: Edge
prerelease: true prerelease: true
draft: false draft: false
body: ${{ github.event.head_commit.message }} body: ${{ github.event.head_commit.message }}
@ -191,7 +209,7 @@ jobs:
upload_release_assets: upload_release_assets:
name: Upload Release Assets name: Upload Release Assets
needs: [build_release_windows, build_release_windows_openmp, build_release_macos, update_edge_release] needs: [build_release_windows, build_release_windows_openmp, build_release_macos, update_edge_release]
if: always() if: "!cancelled()"
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Download All Workflow Artifacts - name: Download All Workflow Artifacts