refact workflow

This commit is contained in:
bonjour 2026-04-08 16:13:36 +08:00
parent 53041906b3
commit d1835a3baa
No known key found for this signature in database
8 changed files with 237 additions and 199 deletions

View file

@ -1,69 +0,0 @@
name: release all platforms
on:
workflow_dispatch:
inputs:
release_tag:
required: false
type: string
jobs:
update:
runs-on: ubuntu-latest
steps:
- name: Trigger build windows
if: github.event.inputs.release_tag != ''
run: |
curl -X POST \
-H "Accept: application/vnd.github.v3+json" \
-H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
https://api.github.com/repos/${{ github.repository }}/actions/workflows/build-windows.yml/dispatches \
-d "{
\"ref\": \"master\",
\"inputs\": {
\"release_tag\": \"${{ github.event.inputs.release_tag }}\"
}
}"
- name: Trigger build linux
if: github.event.inputs.release_tag != ''
run: |
curl -X POST \
-H "Accept: application/vnd.github.v3+json" \
-H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
https://api.github.com/repos/${{ github.repository }}/actions/workflows/build-linux.yml/dispatches \
-d "{
\"ref\": \"master\",
\"inputs\": {
\"release_tag\": \"${{ github.event.inputs.release_tag }}\"
}
}"
- name: Trigger build osx
if: github.event.inputs.release_tag != ''
run: |
curl -X POST \
-H "Accept: application/vnd.github.v3+json" \
-H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
https://api.github.com/repos/${{ github.repository }}/actions/workflows/build-osx.yml/dispatches \
-d "{
\"ref\": \"master\",
\"inputs\": {
\"release_tag\": \"${{ github.event.inputs.release_tag }}\"
}
}"
- name: Trigger build windows desktop
if: github.event.inputs.release_tag != ''
run: |
curl -X POST \
-H "Accept: application/vnd.github.v3+json" \
-H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
https://api.github.com/repos/${{ github.repository }}/actions/workflows/build-windows-desktop.yml/dispatches \
-d "{
\"ref\": \"master\",
\"inputs\": {
\"release_tag\": \"${{ github.event.inputs.release_tag }}\"
}
}"

View file

@ -1,7 +1,7 @@
name: release Linux
on:
workflow_dispatch:
workflow_call:
inputs:
release_tag:
required: false
@ -16,46 +16,41 @@ permissions:
env:
OutputArch: "linux-64"
OutputArchArm: "linux-arm64"
OutputPath64: "${{ github.workspace }}/v2rayN/Release/linux-64"
OutputPath64: "${{ github.workspace }}/v2rayN/Release/linux-x64"
OutputPathArm64: "${{ github.workspace }}/v2rayN/Release/linux-arm64"
jobs:
build:
strategy:
matrix:
configuration: [Release]
arch: [ x64, arm64 ]
uses: ./.github/workflows/build.yml
with:
target: linux
arch: ${{ matrix.arch }}
release-zip:
runs-on: ubuntu-24.04
needs: build
if: inputs.release_tag != ''
steps:
- name: Checkout
uses: actions/checkout@v6.0.2
- name: Restore build artifacts x64
uses: actions/download-artifact@v8
with:
submodules: 'recursive'
fetch-depth: '0'
name: v2rayN-linux-x64
path: ${{ github.workspace }}/v2rayN/Release
- name: Setup .NET
uses: actions/setup-dotnet@v5.2.0
- name: Restore build artifacts arm64
uses: actions/download-artifact@v8
with:
dotnet-version: '8.0.x'
name: v2rayN-linux-arm64
path: ${{ github.workspace }}/v2rayN/Release
- name: Build
run: |
cd v2rayN
dotnet publish ./v2rayN.Desktop/v2rayN.Desktop.csproj -c Release -r linux-x64 -p:SelfContained=true -o "$OutputPath64"
dotnet publish ./v2rayN.Desktop/v2rayN.Desktop.csproj -c Release -r linux-arm64 -p:SelfContained=true -o "$OutputPathArm64"
dotnet publish ./AmazTool/AmazTool.csproj -c Release -r linux-x64 -p:SelfContained=true -p:PublishTrimmed=true -o "$OutputPath64"
dotnet publish ./AmazTool/AmazTool.csproj -c Release -r linux-arm64 -p:SelfContained=true -p:PublishTrimmed=true -o "$OutputPathArm64"
- name: Upload build artifacts
uses: actions/upload-artifact@v7.0.0
with:
name: v2rayN-linux
path: |
${{ github.workspace }}/v2rayN/Release/linux*
# release zip archive
- name: Package release zip archive
if: github.event.inputs.release_tag != ''
run: |
chmod 755 package-release-zip.sh
./package-release-zip.sh "$OutputArch" "$OutputPath64"
@ -63,18 +58,19 @@ jobs:
- name: Upload zip archive to release
uses: svenstaro/upload-release-action@v2
if: github.event.inputs.release_tag != ''
with:
file: ${{ github.workspace }}/v2rayN*.zip
tag: ${{ github.event.inputs.release_tag }}
tag: ${{ inputs.release_tag }}
file_glob: true
prerelease: true
deb:
needs: build
name: build and release deb
if: |
false && (
(github.event_name == 'workflow_dispatch' && github.event.inputs.release_tag != '') ||
(github.event_name == 'push' && startsWith(github.ref, 'refs/tags/'))
)
runs-on: ubuntu-24.04
container:
image: debian:13
@ -130,10 +126,12 @@ jobs:
prerelease: true
rpm:
needs: build
name: build and release rpm
if: |
false && (
(github.event_name == 'workflow_dispatch' && github.event.inputs.release_tag != '') ||
(github.event_name == 'push' && startsWith(github.ref, 'refs/tags/'))
)
runs-on: ubuntu-24.04
container:
image: registry.access.redhat.com/ubi10/ubi
@ -207,12 +205,6 @@ jobs:
submodules: 'recursive'
fetch-depth: '0'
- name: Restore build artifacts
uses: actions/download-artifact@v8
with:
name: v2rayN-linux
path: ${{ github.workspace }}/v2rayN/Release
- name: Ensure script permissions
run: chmod 755 package-rhel.sh

View file

@ -1,7 +1,7 @@
name: release macOS
on:
workflow_dispatch:
workflow_call:
inputs:
release_tag:
required: false
@ -13,63 +13,39 @@ on:
env:
OutputArch: "macos-64"
OutputArchArm: "macos-arm64"
OutputPath64: "${{ github.workspace }}/v2rayN/Release/macos-64"
OutputPath64: "${{ github.workspace }}/v2rayN/Release/macos-x64"
OutputPathArm64: "${{ github.workspace }}/v2rayN/Release/macos-arm64"
jobs:
build:
strategy:
matrix:
configuration: [Release]
arch: [ x64, arm64 ]
uses: ./.github/workflows/build.yml
with:
target: macos
arch: ${{ matrix.arch }}
release-zip:
runs-on: macos-latest
needs: build
if: inputs.release_tag != ''
steps:
- name: Checkout
uses: actions/checkout@v6.0.2
with:
submodules: 'recursive'
fetch-depth: '0'
- name: Setup
uses: actions/setup-dotnet@v5.2.0
- name: Restore build artifacts x64
uses: actions/download-artifact@v8
with:
dotnet-version: '8.0.x'
name: v2rayN-macos-x64
path: ${{ github.workspace }}/v2rayN/Release
- name: Build
run: |
cd v2rayN
dotnet publish ./v2rayN.Desktop/v2rayN.Desktop.csproj -c Release -r osx-x64 -p:SelfContained=true -o $OutputPath64
dotnet publish ./v2rayN.Desktop/v2rayN.Desktop.csproj -c Release -r osx-arm64 -p:SelfContained=true -o $OutputPathArm64
dotnet publish ./AmazTool/AmazTool.csproj -c Release -r osx-x64 -p:SelfContained=true -p:PublishTrimmed=true -o $OutputPath64
dotnet publish ./AmazTool/AmazTool.csproj -c Release -r osx-arm64 -p:SelfContained=true -p:PublishTrimmed=true -o $OutputPathArm64
- name: Upload build artifacts
uses: actions/upload-artifact@v7.0.0
- name: Restore build artifacts arm64
uses: actions/download-artifact@v8
with:
name: v2rayN-macos
path: |
${{ github.workspace }}/v2rayN/Release/macos*
# release osx package
- name: Package osx
if: github.event.inputs.release_tag != ''
run: |
brew install create-dmg
chmod 755 package-osx.sh
./package-osx.sh $OutputArch $OutputPath64 ${{ github.event.inputs.release_tag }}
./package-osx.sh $OutputArchArm $OutputPathArm64 ${{ github.event.inputs.release_tag }}
- name: Upload dmg to release
uses: svenstaro/upload-release-action@v2
if: github.event.inputs.release_tag != ''
with:
file: ${{ github.workspace }}/v2rayN*.dmg
tag: ${{ github.event.inputs.release_tag }}
file_glob: true
prerelease: true
name: v2rayN-macos-arm64
path: ${{ github.workspace }}/v2rayN/Release
# release zip archive
- name: Package release zip archive
if: github.event.inputs.release_tag != ''
run: |
@ -84,4 +60,39 @@ jobs:
file: ${{ github.workspace }}/v2rayN*.zip
tag: ${{ github.event.inputs.release_tag }}
file_glob: true
prerelease: true
release-dmg:
runs-on: macos-latest
needs: build
if: inputs.release_tag != ''
steps:
- name: Checkout
uses: actions/checkout@v6.0.2
- name: Restore build artifacts x64
uses: actions/download-artifact@v8
with:
name: v2rayN-osx-x64
path: ${{ github.workspace }}/v2rayN/Release
- name: Restore build artifacts arm64
uses: actions/download-artifact@v8
with:
name: v2rayN-osx-arm64
path: ${{ github.workspace }}/v2rayN/Release
- name: Package osx
run: |
brew install create-dmg
chmod 755 package-osx.sh
./package-osx.sh $OutputArch $OutputPath64 ${{ github.event.inputs.release_tag }}
./package-osx.sh $OutputArchArm $OutputPathArm64 ${{ github.event.inputs.release_tag }}
- name: Upload dmg to release
uses: svenstaro/upload-release-action@v2
with:
file: ${{ github.workspace }}/v2rayN*.dmg
tag: ${{ github.event.inputs.release_tag }}
file_glob: true
prerelease: true

View file

@ -13,47 +13,40 @@ on:
env:
OutputArch: "windows-64"
OutputArchArm: "windows-arm64"
OutputPath64: "${{ github.workspace }}/v2rayN/Release/windows-64"
OutputPathArm64: "${{ github.workspace }}/v2rayN/Release/windows-arm64"
OutputPath64: "${{ github.workspace }}/v2rayN/Release/windows-desktop-64"
OutputPathArm64: "${{ github.workspace }}/v2rayN/Release/windows-desktop-arm64"
jobs:
build:
strategy:
matrix:
configuration: [Release]
arch: [ x64, arm64 ]
uses: ./.github/workflows/build.yml
with:
target: windows-desktop
arch: ${{ matrix.arch }}
release-zip:
runs-on: ubuntu-latest
needs: build
if: inputs.release_tag != ''
steps:
- name: Checkout
uses: actions/checkout@v6.0.2
- name: Restore build artifacts x64
uses: actions/download-artifact@v8
with:
submodules: 'recursive'
fetch-depth: '0'
name: v2rayN-windows-dekstop-x64
path: ${{ github.workspace }}/v2rayN/Release
- name: Setup
uses: actions/setup-dotnet@v5.2.0
- name: Restore build artifacts arm64
uses: actions/download-artifact@v8
with:
dotnet-version: '8.0.x'
name: v2rayN-windows-dekstop-arm64
path: ${{ github.workspace }}/v2rayN/Release
- name: Build
run: |
cd v2rayN
dotnet publish ./v2rayN.Desktop/v2rayN.Desktop.csproj -c Release -r win-x64 -p:SelfContained=true -p:EnableWindowsTargeting=true -o $OutputPath64
dotnet publish ./v2rayN.Desktop/v2rayN.Desktop.csproj -c Release -r win-arm64 -p:SelfContained=true -p:EnableWindowsTargeting=true -o $OutputPathArm64
dotnet publish ./AmazTool/AmazTool.csproj -c Release -r win-x64 -p:SelfContained=true -p:EnableWindowsTargeting=true -p:PublishTrimmed=true -o $OutputPath64
dotnet publish ./AmazTool/AmazTool.csproj -c Release -r win-arm64 -p:SelfContained=true -p:EnableWindowsTargeting=true -p:PublishTrimmed=true -o $OutputPathArm64
- name: Upload build artifacts
uses: actions/upload-artifact@v7.0.0
with:
name: v2rayN-windows-desktop
path: |
${{ github.workspace }}/v2rayN/Release/windows*
# release zip archive
- name: Package release zip archive
if: github.event.inputs.release_tag != ''
run: |
chmod 755 package-release-zip.sh
./package-release-zip.sh $OutputArch $OutputPath64
@ -63,7 +56,6 @@ jobs:
- name: Upload zip archive to release
uses: svenstaro/upload-release-action@v2
if: github.event.inputs.release_tag != ''
with:
file: ${{ github.workspace }}/v2rayN*.zip
tag: ${{ github.event.inputs.release_tag }}

View file

@ -1,7 +1,7 @@
name: release Windows
on:
workflow_dispatch:
workflow_call:
inputs:
release_tag:
required: false
@ -13,44 +13,40 @@ on:
env:
OutputArch: "windows-64"
OutputArchArm: "windows-arm64"
OutputPath64: "${{ github.workspace }}/v2rayN/Release/windows-64"
OutputPath64: "${{ github.workspace }}/v2rayN/Release/windows-x64"
OutputPathArm64: "${{ github.workspace }}/v2rayN/Release/windows-arm64"
jobs:
build:
strategy:
matrix:
configuration: [Release]
arch: [ x64, arm64 ]
uses: ./.github/workflows/build.yml
with:
target: windows
arch: ${{ matrix.arch }}
release-zip:
runs-on: ubuntu-latest
needs: build
if: inputs.release_tag != ''
steps:
- name: Checkout
uses: actions/checkout@v6.0.2
- name: Setup
uses: actions/setup-dotnet@v5.2.0
- name: Restore build artifacts x64
uses: actions/download-artifact@v8
with:
dotnet-version: '8.0.x'
name: v2rayN-windows-x64
path: ${{ github.workspace }}/v2rayN/Release
- name: Build
run: |
cd v2rayN
dotnet publish ./v2rayN/v2rayN.csproj -c Release -r win-x64 -p:SelfContained=true -p:EnableWindowsTargeting=true -o $OutputPath64
dotnet publish ./v2rayN/v2rayN.csproj -c Release -r win-arm64 -p:SelfContained=true -p:EnableWindowsTargeting=true -o $OutputPathArm64
dotnet publish ./AmazTool/AmazTool.csproj -c Release -r win-x64 -p:SelfContained=true -p:EnableWindowsTargeting=true -p:PublishTrimmed=true -o $OutputPath64
dotnet publish ./AmazTool/AmazTool.csproj -c Release -r win-arm64 -p:SelfContained=true -p:EnableWindowsTargeting=true -p:PublishTrimmed=true -o $OutputPathArm64
- name: Upload build artifacts
uses: actions/upload-artifact@v7.0.0
- name: Restore build artifacts arm64
uses: actions/download-artifact@v8
with:
name: v2rayN-windows
path: |
${{ github.workspace }}/v2rayN/Release/windows*
# release zip archive
name: v2rayN-windows-arm64
path: ${{ github.workspace }}/v2rayN/Release
- name: Package release zip archive
if: github.event.inputs.release_tag != ''
run: |
chmod 755 package-release-zip.sh
./package-release-zip.sh $OutputArch $OutputPath64
@ -58,7 +54,6 @@ jobs:
- name: Upload zip archive to release
uses: svenstaro/upload-release-action@v2
if: github.event.inputs.release_tag != ''
with:
file: ${{ github.workspace }}/v2rayN*.zip
tag: ${{ github.event.inputs.release_tag }}

78
.github/workflows/build.yml vendored Normal file
View file

@ -0,0 +1,78 @@
name: build v2rayN
on:
workflow_call:
inputs:
target: # windows linux macos windows-desktop
required: true
type: string
arch: # x64 arm64
required: true
type: string
permissions:
contents: write
env:
OutputPath: "${{ github.workspace }}/v2rayN/Release/${{ inputs.target }}-${{ inputs.arch }}"
RID: |-
${{
case(
inputs.target == macos, format('osx-{0}', inputs.arch),
startsWith(inputs.target, 'windows'), format('win-{0}', inputs.arch),
format('{0}-{1}', inputs.target, inputs.arch)
)
}}
Project: |-
${{
case(
inputs.target == 'windows', './v2rayN/v2rayN.csproj',
'./v2rayN.Desktop/v2rayN.Desktop.csproj'
)
}}
ExtOpt: |-
${{
case(
startsWith(inputs.target, 'windows'), '-p:EnableWindowsTargeting=true',
''
)
}}
jobs:
build:
runs-on: |-
${{
case(
inputs.target == macos, 'macos-latest',
inputs.target == linux, 'ubuntu-24.04',
'ubuntu-latest'
)
}}
steps:
- name: Checkout
uses: actions/checkout@v6.0.2
with:
submodules: 'recursive'
fetch-depth: '0'
- name: Setup .NET
uses: actions/setup-dotnet@v5.2.0
with:
dotnet-version: '8.0.x'
- name: Build v2rayN
working-directory: ./v2rayN
run: dotnet publish ./AmazTool/AmazTool.csproj -c Release -r $RID -p:SelfContained=true -p:PublishTrimmed=true $ExtOpt -o $OutputPath
- name: Build AmazTool
working-directory: ./v2rayN
run: dotnet publish ./AmazTool/AmazTool.csproj -c Release -r $RID -p:SelfContained=true -p:PublishTrimmed=true $ExtOpt -o $OutputPath
- name: Upload build artifacts
uses: actions/upload-artifact@v7.0.0
with:
name: v2rayN-${{ inputs.target }}-${{ inputs.arch }}
path: |
${{ github.workspace }}/v2rayN/Release/${{ inputs.target }}-${{ inputs.arch }}

39
.github/workflows/release.yml vendored Normal file
View file

@ -0,0 +1,39 @@
name: release all platforms
on:
workflow_dispatch:
inputs:
release_tag:
required: false
type: string
permissions:
contents: write
jobs:
windows:
name: build and release windows
if: inputs.release_tag != ''
permissions:
contents: write
uses: ./.github/workflows/build-windows.yml
with:
release_tag: ${{ inputs.release_tag }}
linux:
name: build and release linux
if: inputs.release_tag != ''
permissions:
contents: write
uses: ./.github/workflows/build-linux.yml
with:
release_tag: ${{ inputs.release_tag }}
osx:
name: build and release osx
if: inputs.release_tag != ''
permissions:
contents: write
uses: ./.github/workflows/build-osx.yml
with:
release_tag: ${{ inputs.release_tag }}

View file

@ -4,7 +4,7 @@ name: WinGet submission on release
# Modified by @MerrickZ https://github.com/anpho
on:
workflow_dispatch:
workflow_call:
release:
types: [released]