ci: make release step create draft prereleases for PRs

Update the GitHub release action to mark releases from pull 
request events as prerelease and to set a safe tag name when the
 is not triggered by a tag ref.

- Set prerelease to true when github.event_name == 'pull_request'
  so draft releases created during PR workflows are marked as
  prereleases.
- Use the tag name from github.ref_name when the workflow is
  triggered by a tag; otherwise generate a deterministic test tag
  "test-<sha>" to avoid using an invalid or empty tag name.

This prevents accidental full releases from PR runs and ensures the
action always has a valid tag_name value.
This commit is contained in:
4gray committed 2025-11-08 23:02:15 +01:00
1 parent ea3c2b1e45
commit fbed100fb0
1 file changed
+12 -3
+12 -3
View File
@@ -110,11 +110,20 @@ jobs:
uses: softprops/action-gh-release@v2
with:
draft: true
prerelease: false
prerelease: ${{ github.event_name == 'pull_request' }}
name: Release v${{ steps.package-version.outputs.version }}
tag_name: ${{ github.ref_name }}
tag_name: ${{ startsWith(github.ref, 'refs/tags/') && github.ref_name || format('test-{0}', github.sha) }}
generate_release_notes: true
files: |
artifacts/**/*
artifacts/macos-artifacts/*.dmg
artifacts/macos-artifacts/*.zip
artifacts/linux-artifacts/*.AppImage
artifacts/linux-artifacts/*.deb
artifacts/linux-artifacts/*.rpm
artifacts/linux-artifacts/*.snap
artifacts/linux-artifacts/*.tar.gz
artifacts/windows-artifacts/*-setup.exe
artifacts/windows-artifacts/*.msi
artifacts/windows-artifacts/*.zip
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}