Skip to content

Commit f4ad820

Browse files
ppdphkahler
authored andcommitted
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.
1 parent af5fbf6 commit f4ad820

File tree

1 file changed

+31
-13
lines changed

1 file changed

+31
-13
lines changed

.github/workflows/cd.yml

Lines changed: 31 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,19 +9,32 @@ on:
99
- created
1010

1111
jobs:
12+
cancel_previous_runs:
13+
runs-on: ubuntu-latest
14+
name: Cancel Previous Runs
15+
if: github.event_name == 'push'
16+
steps:
17+
- uses: styfle/[email protected]
18+
with:
19+
access_token: ${{ github.token }}
20+
1221
test_ubuntu:
13-
runs-on: ubuntu-18.04
14-
name: Test Ubuntu
15-
steps:
16-
- uses: actions/checkout@v2
17-
- name: Install Dependencies
18-
run: .github/scripts/install-ubuntu.sh
19-
- name: Build & Test
20-
run: .github/scripts/build-ubuntu.sh
22+
needs: [cancel_previous_runs]
23+
runs-on: ubuntu-18.04
24+
name: Test Ubuntu
25+
if: "!cancelled()"
26+
steps:
27+
- uses: actions/checkout@v2
28+
- name: Install Dependencies
29+
run: .github/scripts/install-ubuntu.sh
30+
- name: Build & Test
31+
run: .github/scripts/build-ubuntu.sh
2132

2233
test_windows:
34+
needs: [cancel_previous_runs]
2335
runs-on: windows-2019
2436
name: Test Windows
37+
if: "!cancelled()"
2538
steps:
2639
- uses: actions/checkout@v2
2740
- name: Install Dependencies
@@ -32,8 +45,10 @@ jobs:
3245
shell: bash
3346

3447
test_macos:
48+
needs: [cancel_previous_runs]
3549
runs-on: macos-10.15
3650
name: Test macOS
51+
if: "!cancelled()"
3752
steps:
3853
- uses: actions/checkout@v2
3954
- name: Install Dependencies
@@ -164,34 +179,37 @@ jobs:
164179
update_edge_release:
165180
name: Update Edge Release
166181
needs: [build_release_windows, build_release_windows_openmp, build_release_macos]
167-
if: always() && github.event_name == 'push'
182+
if: github.event_name == 'push' && !cancelled()
168183
runs-on: ubuntu-latest
169184
outputs:
170185
upload_url: ${{ steps.create_release.outputs.upload_url }}
171186
steps:
172187
- name: Delete Old Edge Release
173-
uses: dev-drprasad/delete-tag-and-release@v0.1.2
188+
uses: dev-drprasad/delete-tag-and-release@v0.2.0
174189
with:
175190
delete_release: true
176191
tag_name: edge
177192
env:
178193
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
194+
- name: Wait
195+
shell: bash
196+
run: sleep 60
179197
- name: Create New Edge Release
180198
id: create_release
181-
uses: actions/create-release@v1
199+
uses: softprops/action-gh-release@35d938cf01f60fbe522917c81be1e892074f6ad6
182200
env:
183201
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
184202
with:
185203
tag_name: edge
186-
release_name: Edge
204+
name: Edge
187205
prerelease: true
188206
draft: false
189207
body: ${{ github.event.head_commit.message }}
190208

191209
upload_release_assets:
192210
name: Upload Release Assets
193211
needs: [build_release_windows, build_release_windows_openmp, build_release_macos, update_edge_release]
194-
if: always()
212+
if: "!cancelled()"
195213
runs-on: ubuntu-latest
196214
steps:
197215
- name: Download All Workflow Artifacts

0 commit comments

Comments
 (0)