Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 23 additions & 6 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ on:
tags:
- v*
pull_request:
release:
types: [created, published]
workflow_dispatch:

permissions:
Expand Down Expand Up @@ -106,7 +108,7 @@ jobs:
dotnet test WhileLoopTimeout.sln --configuration Release --no-build

- name: Prepare release assets
if: startsWith(github.ref, 'refs/tags/v')
if: startsWith(github.ref, 'refs/tags/v') || github.event_name == 'release'
shell: bash
run: |
set -euo pipefail
Expand All @@ -118,7 +120,7 @@ jobs:
fi

- name: Upload release artifacts
if: startsWith(github.ref, 'refs/tags/v')
if: startsWith(github.ref, 'refs/tags/v') || github.event_name == 'release'
uses: actions/upload-artifact@v4
with:
name: while-loop-timeout
Expand All @@ -128,7 +130,7 @@ jobs:
release:
runs-on: ubuntu-latest
needs: build
if: startsWith(github.ref, 'refs/tags/v')
if: startsWith(github.ref, 'refs/tags/v') || github.event_name == 'release'
permissions:
contents: write
steps:
Expand All @@ -138,12 +140,27 @@ jobs:
name: while-loop-timeout
path: release-artifacts

- name: Determine release tag
id: tag
shell: bash
run: |
if [ "${{ github.event_name }}" = "release" ]; then
echo "tag_name=${{ github.event.release.tag_name }}" >> "$GITHUB_OUTPUT"
elif [[ "${{ github.ref }}" == refs/tags/* ]]; then
echo "tag_name=${{ github.ref_name }}" >> "$GITHUB_OUTPUT"
else
echo "::error::Unexpected event: ${{ github.event_name }} with ref: ${{ github.ref }}"
exit 1
fi

- name: Publish GitHub release
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ github.ref_name }}
name: While Loop Timeout ${{ github.ref_name }}
generate_release_notes: true
tag_name: ${{ steps.tag.outputs.tag_name }}
name: While Loop Timeout ${{ steps.tag.outputs.tag_name }}
# When triggered by release event, this updates the existing release
# When triggered by tag push, this creates a new release
generate_release_notes: ${{ github.event_name != 'release' }}
Comment on lines 156 to +163

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Allow action-gh-release to update existing releases

With the new release trigger, this job now runs after a release has already been created via the UI. softprops/action-gh-release@v2 defaults to creating a release and returns a 422 error if the tag already exists unless allow_updates or update_only is supplied. Because the step omits those inputs, a run triggered by release.created/release.published will fail before assets are uploaded, defeating the purpose of the change. Consider enabling updates when github.event_name == 'release' so the action modifies the existing release instead of attempting to recreate it.

Useful? React with 👍 / 👎.

files: |
release-artifacts/WhileLoopTimeout.dll
release-artifacts/WhileLoopTimeout.pdb