Skip to content

Commit 853f474

Browse files
Copilotesnya
andcommitted
Add release event trigger to CI workflow for automatic releases
This fixes the issue where creating a release through the GitHub UI doesn't trigger the build and asset upload workflow. Now the workflow will trigger on both: 1. Tag pushes (existing behavior) 2. Release creation/publication events (new behavior) The workflow determines the correct tag name based on the event type and handles both cases appropriately. Co-authored-by: esnya <2088693+esnya@users.noreply.github.com>
1 parent 1e09aa1 commit 853f474

1 file changed

Lines changed: 17 additions & 5 deletions

File tree

.github/workflows/ci.yml

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ on:
77
tags:
88
- v*
99
pull_request:
10+
release:
11+
types: [created, published]
1012
workflow_dispatch:
1113

1214
permissions:
@@ -106,7 +108,7 @@ jobs:
106108
dotnet test WhileLoopTimeout.sln --configuration Release --no-build
107109
108110
- name: Prepare release assets
109-
if: startsWith(github.ref, 'refs/tags/v')
111+
if: startsWith(github.ref, 'refs/tags/v') || github.event_name == 'release'
110112
shell: bash
111113
run: |
112114
set -euo pipefail
@@ -118,7 +120,7 @@ jobs:
118120
fi
119121
120122
- name: Upload release artifacts
121-
if: startsWith(github.ref, 'refs/tags/v')
123+
if: startsWith(github.ref, 'refs/tags/v') || github.event_name == 'release'
122124
uses: actions/upload-artifact@v4
123125
with:
124126
name: while-loop-timeout
@@ -128,7 +130,7 @@ jobs:
128130
release:
129131
runs-on: ubuntu-latest
130132
needs: build
131-
if: startsWith(github.ref, 'refs/tags/v')
133+
if: startsWith(github.ref, 'refs/tags/v') || github.event_name == 'release'
132134
permissions:
133135
contents: write
134136
steps:
@@ -138,11 +140,21 @@ jobs:
138140
name: while-loop-timeout
139141
path: release-artifacts
140142

143+
- name: Determine release tag
144+
id: tag
145+
shell: bash
146+
run: |
147+
if [ "${{ github.event_name }}" = "release" ]; then
148+
echo "tag_name=${{ github.event.release.tag_name }}" >> "$GITHUB_OUTPUT"
149+
else
150+
echo "tag_name=${{ github.ref_name }}" >> "$GITHUB_OUTPUT"
151+
fi
152+
141153
- name: Publish GitHub release
142154
uses: softprops/action-gh-release@v2
143155
with:
144-
tag_name: ${{ github.ref_name }}
145-
name: While Loop Timeout ${{ github.ref_name }}
156+
tag_name: ${{ steps.tag.outputs.tag_name }}
157+
name: While Loop Timeout ${{ steps.tag.outputs.tag_name }}
146158
generate_release_notes: true
147159
files: |
148160
release-artifacts/WhileLoopTimeout.dll

0 commit comments

Comments
 (0)