|
1 | 1 | name: Create Github Release |
2 | 2 |
|
3 | 3 | on: |
4 | | - push: |
5 | | - tags: |
6 | | - - "v[0-9]+.[0-9]+.[0-9]+" |
7 | | - - "v[0-9]+.[0-9]+.[0-9]+[a-zA-Z]+[0-9]*" |
| 4 | + workflow_run: |
| 5 | + workflows: ["Run Tests"] |
| 6 | + types: |
| 7 | + - completed |
| 8 | + branches: |
| 9 | + - '**' |
8 | 10 | workflow_dispatch: |
9 | 11 | inputs: |
10 | 12 | tag: |
|
15 | 17 | jobs: |
16 | 18 | create-release: |
17 | 19 | runs-on: ubuntu-latest |
| 20 | + # Only run if tests passed and this is a tag push, or manual dispatch |
| 21 | + if: | |
| 22 | + github.event_name == 'workflow_dispatch' || |
| 23 | + (github.event.workflow_run.conclusion == 'success' && startsWith(github.event.workflow_run.head_branch, 'refs/tags/v')) |
18 | 24 |
|
19 | 25 | permissions: |
20 | 26 | contents: write |
21 | 27 |
|
22 | 28 | steps: |
23 | 29 | - name: Checkout code |
24 | | - uses: actions/checkout@v4 |
| 30 | + uses: actions/checkout@v6 |
| 31 | + with: |
| 32 | + ref: ${{ (github.event_name == 'workflow_dispatch' && github.event.inputs.tag) || github.event.workflow_run.head_branch }} |
25 | 33 |
|
26 | 34 | - name: Extract version information |
27 | 35 | id: version_info |
|
30 | 38 | if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then |
31 | 39 | VERSION="${{ github.event.inputs.tag }}" |
32 | 40 | else |
33 | | - VERSION="${{ github.ref_name }}" |
| 41 | + VERSION="${{ github.event.workflow_run.head_branch }}" |
34 | 42 | fi |
35 | 43 |
|
36 | 44 | echo "version=$VERSION" >> $GITHUB_OUTPUT |
@@ -85,13 +93,13 @@ jobs: |
85 | 93 | id: create_release |
86 | 94 | run: | |
87 | 95 | if [ "${{ steps.version_info.outputs.is_prerelease }}" = "true" ]; then |
88 | | - echo "Create release for version ${{ github.ref_name }} (Pre-release)" |
| 96 | + echo "Create release for version ${{ steps.version_info.outputs.version }} (Pre-release)" |
89 | 97 | gh release create "${{ steps.version_info.outputs.version }}" \ |
90 | 98 | --title "${{ steps.version_info.outputs.release_name }}" \ |
91 | 99 | --notes-file release_notes.md \ |
92 | 100 | --prerelease |
93 | 101 | else |
94 | | - echo "Create release for version ${{ github.ref_name }}" |
| 102 | + echo "Create release for version ${{ steps.version_info.outputs.version }}" |
95 | 103 | gh release create "${{ steps.version_info.outputs.version }}" \ |
96 | 104 | --title "${{ steps.version_info.outputs.release_name }}" \ |
97 | 105 | --notes-file release_notes.md |
|
0 commit comments