|
1 | 1 | name: CD |
2 | 2 | concurrency: cd |
3 | 3 |
|
4 | | -# Trigger workflow on release tag push |
| 4 | +# Trigger workflow on completed CI (further checks below) |
5 | 5 | on: |
6 | | - push: |
7 | | - # TODO: Should we restrict to vX.Y.Z tags? |
8 | | - tags: v* |
| 6 | + workflow_run: |
| 7 | + workflows: [CI] |
| 8 | + types: [completed] |
9 | 9 |
|
10 | 10 | jobs: |
11 | 11 | build: |
12 | 12 | name: Build |
13 | 13 | runs-on: ubuntu-latest |
| 14 | + # Skip unless CI was successful and ran on a ref starting with 'v' (release tag) |
| 15 | + if: ${{ github.event.workflow_run.conclusion == 'success' && startsWith(github.event.workflow_run.head_branch, 'v') }} |
| 16 | + # NOTE: This works because we currently only trigger CI on a push to the 'develop' |
| 17 | + # branch or a 'v*'-tag, but it seems rather brittle. |
| 18 | + # Unfortunately, there is not much more info we get from the CI workflow |
| 19 | + # ('workflow_run') than the ref name. No ref, ref_type, etc., so we don't even know |
| 20 | + # if a tag or a branch was pushed. :( |
| 21 | + # See https://docs.github.com/en/developers/webhooks-and-events/webhooks/webhook-events-and-payloads#workflow_run |
| 22 | + # NOTE: (2) An alternative solution might be to restructure workflows, so that all |
| 23 | + # test logic from 'ci.yml' is moved to a separate workflow file '_test.yml', that |
| 24 | + # can be included in both CI (triggered on push to 'develop'-branch) and CD |
| 25 | + # (triggered on push to 'v*'-tag) workflows. |
14 | 26 | outputs: |
15 | 27 | release_id: ${{ steps.gh-release.outputs.id }} |
16 | 28 | steps: |
17 | 29 | - name: Checkout release tag |
18 | 30 | uses: actions/checkout@a12a3943b4bdde767164f792f33f40b04645d846 |
| 31 | + with: |
| 32 | + ref: ${{ github.event.workflow_run.head_branch }} |
19 | 33 |
|
20 | 34 | - name: Set up Python |
21 | 35 | uses: actions/setup-python@0ebf233433c08fb9061af664d501c3f3ff0e9e20 |
|
32 | 46 | name: Publish GitHub release candiate |
33 | 47 | uses: softprops/action-gh-release@1e07f4398721186383de40550babbdf2b84acfc5 |
34 | 48 | with: |
35 | | - name: ${{ github.ref_name }}-rc |
36 | | - tag_name: ${{ github.ref }} |
| 49 | + name: ${{ github.event.workflow_run.head_branch }}-rc |
| 50 | + tag_name: ${{ github.event.workflow_run.head_branch }} |
37 | 51 | body: "Release waiting for review..." |
38 | 52 | files: dist/* |
39 | 53 |
|
|
75 | 89 | owner: context.repo.owner, |
76 | 90 | repo: context.repo.repo, |
77 | 91 | release_id: '${{ needs.build.outputs.release_id }}', |
78 | | - name: '${{ github.ref_name }}', |
79 | | - body: 'See [CHANGELOG.md](https://github.com/'+ context.repo.owner +'/'+ context.repo.repo +'/blob/${{ github.ref_name }}/docs/CHANGELOG.md) for details.' |
| 92 | + name: '${{ github.event.workflow_run.head_branch }}', |
| 93 | + body: 'See [CHANGELOG.md](https://github.com/'+ context.repo.owner +'/'+ context.repo.repo +'/blob/${{ github.event.workflow_run.head_branch }}/docs/CHANGELOG.md) for details.' |
80 | 94 | }) |
0 commit comments