mirror of
https://github.com/2dust/v2rayN.git
synced 2026-11-01 18:15:00 +03:00
78b0b2224b
* Protect models * Json Context * YAML AOT-friendly optimization * Run the Test in AOT mode * Remove TaskScheduler * Clean build output * Workflows
140 lines
4.2 KiB
YAML
140 lines
4.2 KiB
YAML
name: build
|
|
|
|
on:
|
|
workflow_call:
|
|
inputs:
|
|
target: # windows linux macos
|
|
required: true
|
|
type: string
|
|
project:
|
|
required: false
|
|
type: string
|
|
default: './v2rayN.Desktop/v2rayN.Desktop.csproj'
|
|
isAot:
|
|
required: false
|
|
type: boolean
|
|
default: false
|
|
|
|
jobs:
|
|
build:
|
|
name: build x64 arm64
|
|
strategy:
|
|
matrix:
|
|
arch: [ x64, arm64 ]
|
|
runs-on: |-
|
|
${{
|
|
case(
|
|
inputs.target == 'macos', 'macos-latest',
|
|
inputs.target == 'linux', 'ubuntu-24.04',
|
|
inputs.target == 'windows', 'windows-latest',
|
|
'ubuntu-latest'
|
|
)
|
|
}}
|
|
env:
|
|
RID: |-
|
|
${{
|
|
case(
|
|
inputs.target == 'macos', format('osx-{0}', matrix.arch),
|
|
inputs.target == 'windows', format('win-{0}', matrix.arch),
|
|
format('{0}-{1}', inputs.target, matrix.arch)
|
|
)
|
|
}}
|
|
Project: ${{ inputs.project }}
|
|
ExtOpt: |-
|
|
${{
|
|
case(
|
|
inputs.target == 'windows', '-p:EnableWindowsTargeting=true',
|
|
inputs.target == 'linux', (matrix.arch == 'arm64' && '-p:LinkerFlavor=lld -p:ObjCopyName=llvm-objcopy' || ''),
|
|
''
|
|
)
|
|
}}
|
|
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v7
|
|
with:
|
|
submodules: 'recursive'
|
|
fetch-depth: '0'
|
|
|
|
- name: Purge SDKs
|
|
shell: pwsh
|
|
run: |
|
|
echo "Before:"
|
|
dotnet --list-sdks
|
|
|
|
dotnet --list-sdks | % {
|
|
$_ -match '^\S+\s+\[(.+)\]$' > $null
|
|
$d = Join-Path $Matches[1] $_.Split()[0]
|
|
Write-Host "Removing $d"
|
|
if ($IsWindows) { rm $d -r -fo } else { sudo rm -rf "$d" }
|
|
}
|
|
|
|
echo "After:"
|
|
dotnet --list-sdks 2>$null; $LASTEXITCODE=0
|
|
|
|
- name: Setup .NET
|
|
uses: actions/setup-dotnet@v6
|
|
with:
|
|
dotnet-version: 10.0.x
|
|
|
|
- name: Install dependencies
|
|
shell: bash
|
|
if: inputs.target == 'linux' && inputs.isAot
|
|
run: |
|
|
sudo apt-get update
|
|
sudo apt-get install -y clang zlib1g-dev build-essential
|
|
|
|
- name: Install dependencies cross-arch
|
|
shell: bash
|
|
if: inputs.target == 'linux' && inputs.isAot && matrix.arch == 'arm64'
|
|
run: |
|
|
sudo apt-get update
|
|
sudo apt-get install -y lld llvm binutils-aarch64-linux-gnu gcc-aarch64-linux-gnu g++-aarch64-linux-gnu libc6-dev-arm64-cross
|
|
|
|
- name: Set AOT Environment Variable
|
|
shell: bash
|
|
run: |
|
|
if [ "${{ inputs.isAot }}" = "true" ]; then
|
|
echo "DOTNET_AOT_ARG=-p:IsAot=true" >> $GITHUB_ENV
|
|
else
|
|
echo "DOTNET_AOT_ARG=-p:IsAot=false" >> $GITHUB_ENV
|
|
fi
|
|
|
|
- name: Set OUTPUT Environment Variable
|
|
shell: bash
|
|
run: |
|
|
RAW_PATH="${{ github.workspace }}/${{ matrix.arch }}${{ inputs.isAot && '-aot' || '' }}"
|
|
echo "OUTPUT=${RAW_PATH//\\//}" >> "$GITHUB_ENV"
|
|
|
|
- name: Build AmazTool
|
|
shell: bash
|
|
working-directory: ./v2rayN
|
|
run: dotnet publish ./AmazTool/AmazTool.csproj -c Release -r $RID -p:SelfContained=true -p:PublishTrimmed=true $ExtOpt ${{ env.DOTNET_AOT_ARG }} -o ${{ env.OUTPUT }}
|
|
|
|
- name: Build v2rayN WPF
|
|
shell: bash
|
|
if: inputs.project == './v2rayN/v2rayN.csproj'
|
|
working-directory: ./v2rayN
|
|
run: dotnet publish $Project -c Release -r $RID -p:SelfContained=true $ExtOpt -o ${{ env.OUTPUT }}
|
|
|
|
- name: Build v2rayN Avalonia
|
|
shell: bash
|
|
if: inputs.project == './v2rayN.Desktop/v2rayN.Desktop.csproj'
|
|
working-directory: ./v2rayN
|
|
run: dotnet publish $Project -c Release -r $RID -p:SelfContained=true $ExtOpt ${{ env.DOTNET_AOT_ARG }} -o ${{ env.OUTPUT }}
|
|
|
|
- name: Remove Debug Symbols
|
|
shell: bash
|
|
run: |
|
|
find ${{ env.OUTPUT }} -type f -name '*.pdb' -delete
|
|
find ${{ env.OUTPUT }} -type f -name '*.debug' -delete
|
|
find ${{ env.OUTPUT }} -type f -name '*.dbg' -delete
|
|
find ${{ env.OUTPUT }} -type f -name '*.sym' -delete
|
|
find ${{ env.OUTPUT }} -name '*.dSYM' -exec rm -rf {} +
|
|
|
|
- name: Upload build artifacts
|
|
uses: actions/upload-artifact@v7
|
|
with:
|
|
name: ${{ matrix.arch }}${{ inputs.isAot && '-aot' || '' }}
|
|
path: ${{ env.OUTPUT }}
|