修复标签推送自动创建 Release

- 添加 tags 触发器支持 v* 格式的标签
- 标签推送时自动创建 GitHub Release
- 自动上传二进制文件到 Release
This commit is contained in:
EUForest 2025-11-24 18:21:56 +08:00
parent e062dc1ab0
commit b8a4b73bb0

View File

@ -3,6 +3,9 @@ name: Build Linux Binary
on:
push:
branches: [ main, master ]
push:
tags:
- 'v*'
workflow_dispatch:
inputs:
version:
@ -89,16 +92,23 @@ jobs:
retention-days: 30
- name: Create and Upload to GitHub Release
if: github.event_name == 'release' || github.event.inputs.create_release == 'true'
if: github.event_name == 'release' || github.event.inputs.create_release == 'true' || startsWith(github.ref, 'refs/tags/')
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
# Create release if it doesn't exist
if [ "${{ github.event.inputs.create_release }}" = "true" ] && [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
echo "Creating release for ${{ env.VERSION }}"
gh release create ${{ env.VERSION }} \
--title "PPanel Server ${{ env.VERSION }}" \
--notes "Release ${{ env.VERSION }}" \
--latest
elif [ "${{ github.event_name }}" = "push" ] && [ "${{ github.ref_type }}" = "tag" ]; then
echo "Creating release for tag ${{ env.VERSION }}"
gh release create ${{ env.VERSION }} \
--title "PPanel Server ${{ env.VERSION }}" \
--notes "Release ${{ env.VERSION }}" \
--latest
fi
echo "Uploading binaries to release ${{ env.VERSION }}"