|
2 | 2 | name: Release |
3 | 3 |
|
4 | 4 | on: |
5 | | - workflow_run: |
6 | | - workflows: |
7 | | - - "CI" |
8 | | - types: |
9 | | - - completed |
| 5 | + push: |
| 6 | + tags: |
| 7 | + - v*.*.* |
10 | 8 |
|
11 | 9 | jobs: |
12 | | - validate-tag: |
13 | | - name: Check tag |
| 10 | + wait-for-ci: |
| 11 | + name: Wait for CI |
14 | 12 | runs-on: ubuntu-latest |
15 | | - outputs: |
16 | | - valid_tag: ${{ steps.validation.outputs.valid_tag }} |
17 | | - if: ${{ github.event.workflow_run.conclusion == 'success' && github.event.workflow_run.event == 'push' && startsWith(github.event.workflow_run.head_branch, 'v') }} |
18 | 13 | steps: |
19 | | - - name: Check out the repository including tags |
20 | | - uses: actions/checkout@v6 |
| 14 | + - name: Wait for CI to pass |
| 15 | + uses: lewagon/wait-on-check-action@v1.5.0 |
21 | 16 | with: |
22 | | - ref: ${{ github.event.workflow_run.head_sha }} |
23 | | - fetch-depth: 0 |
24 | | - fetch-tags: true |
25 | | - - name: Validate tag |
26 | | - id: validation |
27 | | - run: | |
28 | | - # Validation is necessary in the unlikely case that a branch matching the tag naming pattern is pushed |
29 | | - # and the CI workflow in that branch is modified to run upon a push to that branch |
30 | | - REF='${{ github.event.workflow_run.head_branch }}' # This can be a branch or tag name |
31 | | - if [[ "$REF" != v*.*.* ]]; then |
32 | | - echo "valid_tag=false" >> "$GITHUB_OUTPUT"; exit 0 |
33 | | - fi |
34 | | - # Validate that the tag exists |
35 | | - if ! git rev-parse -q --verify "refs/tags/$REF" >/dev/null; then |
36 | | - echo "There is no tag matching $REF - $REF is a branch" |
37 | | - echo "valid_tag=false" >> "$GITHUB_OUTPUT"; exit 0 |
38 | | - fi |
39 | | - # Validate that the tag is for the same commit that was pushed |
40 | | - TAG_SHA="$(git rev-parse "$REF^{commit}")" |
41 | | - COMMIT_SHA="${{ github.event.workflow_run.head_sha }}" |
42 | | - if [ "$TAG_SHA" != "$COMMIT_SHA" ]; then |
43 | | - echo "Tag SHA $TAG_SHA does not match pushed commit SHA $COMMIT_SHA" |
44 | | - echo "valid_tag=false" >> "$GITHUB_OUTPUT"; exit 0 |
45 | | - fi |
46 | | - echo "Tag $REF exists and is valid. Tag $TAG_SHA matches the pushed commit $COMMIT_SHA." |
47 | | - echo "valid_tag=true" >> "$GITHUB_OUTPUT" |
| 17 | + ref: ${{ github.sha }} |
| 18 | + running-workflow-name: Wait for CI |
| 19 | + repo-token: ${{ secrets.GITHUB_TOKEN }} |
| 20 | + wait-interval: 10 |
| 21 | + |
48 | 22 | publish: |
49 | 23 | name: Publish to PyPI |
50 | | - needs: validate-tag |
| 24 | + needs: wait-for-ci |
51 | 25 | runs-on: ubuntu-latest |
52 | | - if: ${{ needs.validate-tag.outputs.valid_tag == 'true' && github.event.workflow_run.conclusion == 'success' }} |
53 | 26 | steps: |
54 | 27 | - uses: actions/checkout@v6 |
55 | 28 |
|
|
0 commit comments