mirror of
https://github.com/2dust/v2rayN.git
synced 2026-11-02 02:25:01 +03:00
Native Aot (#10295)
* Protect models * Json Context * YAML AOT-friendly optimization * Run the Test in AOT mode * Remove TaskScheduler * Clean build output * Workflows
This commit is contained in:
@@ -29,6 +29,22 @@ jobs:
|
||||
release_tag: ${{ inputs.release_tag }}
|
||||
secrets: inherit
|
||||
|
||||
build-aot:
|
||||
uses: ./.github/workflows/build.yml
|
||||
with:
|
||||
target: linux
|
||||
isAot: true
|
||||
|
||||
release-aot-zip:
|
||||
if: inputs.release_tag != ''
|
||||
needs: build-aot
|
||||
uses: ./.github/workflows/package-zip.yml
|
||||
with:
|
||||
target: linux
|
||||
release_tag: ${{ inputs.release_tag }}
|
||||
isAot: true
|
||||
secrets: inherit
|
||||
|
||||
deb:
|
||||
name: build and release deb x64 & arm64
|
||||
if: (github.event_name == 'workflow_dispatch' && inputs.release_tag != '') || (github.event_name == 'push' && startsWith(github.ref, 'refs/tags/'))
|
||||
|
||||
@@ -28,7 +28,23 @@ jobs:
|
||||
target: macos
|
||||
release_tag: ${{ inputs.release_tag }}
|
||||
secrets: inherit
|
||||
|
||||
|
||||
build-aot:
|
||||
uses: ./.github/workflows/build.yml
|
||||
with:
|
||||
target: macos
|
||||
isAot: true
|
||||
|
||||
release-aot-zip:
|
||||
if: inputs.release_tag != ''
|
||||
needs: build-aot
|
||||
uses: ./.github/workflows/package-zip.yml
|
||||
with:
|
||||
target: macos
|
||||
release_tag: ${{ inputs.release_tag }}
|
||||
isAot: true
|
||||
secrets: inherit
|
||||
|
||||
dmg:
|
||||
name: package and release macOS dmg
|
||||
if: inputs.release_tag != ''
|
||||
|
||||
@@ -28,3 +28,19 @@ jobs:
|
||||
target: windows-desktop
|
||||
release_tag: ${{ inputs.release_tag }}
|
||||
secrets: inherit
|
||||
|
||||
build-aot:
|
||||
uses: ./.github/workflows/build.yml
|
||||
with:
|
||||
target: windows
|
||||
isAot: true
|
||||
|
||||
release-aot-zip:
|
||||
if: inputs.release_tag != ''
|
||||
needs: build-aot
|
||||
uses: ./.github/workflows/package-zip.yml
|
||||
with:
|
||||
target: windows-desktop
|
||||
release_tag: ${{ inputs.release_tag }}
|
||||
isAot: true
|
||||
secrets: inherit
|
||||
|
||||
+54
-10
@@ -10,6 +10,10 @@ on:
|
||||
required: false
|
||||
type: string
|
||||
default: './v2rayN.Desktop/v2rayN.Desktop.csproj'
|
||||
isAot:
|
||||
required: false
|
||||
type: boolean
|
||||
default: false
|
||||
|
||||
jobs:
|
||||
build:
|
||||
@@ -27,7 +31,6 @@ jobs:
|
||||
)
|
||||
}}
|
||||
env:
|
||||
Output: "${{ github.workspace }}/${{ matrix.arch }}"
|
||||
RID: |-
|
||||
${{
|
||||
case(
|
||||
@@ -41,6 +44,7 @@ jobs:
|
||||
${{
|
||||
case(
|
||||
inputs.target == 'windows', '-p:EnableWindowsTargeting=true',
|
||||
inputs.target == 'linux', (matrix.arch == 'arm64' && '-p:LinkerFlavor=lld -p:ObjCopyName=llvm-objcopy' || ''),
|
||||
''
|
||||
)
|
||||
}}
|
||||
@@ -71,25 +75,65 @@ jobs:
|
||||
- name: Setup .NET
|
||||
uses: actions/setup-dotnet@v6
|
||||
with:
|
||||
dotnet-version: 10.0.1xx
|
||||
|
||||
- name: Build v2rayN
|
||||
dotnet-version: 10.0.x
|
||||
|
||||
- name: Install dependencies
|
||||
shell: bash
|
||||
working-directory: ./v2rayN
|
||||
run: dotnet publish $Project -c Release -r $RID -p:SelfContained=true $ExtOpt -o $Output
|
||||
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 -o $Output
|
||||
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 ${{ matrix.arch }} -type f -name '*.pdb' -delete
|
||||
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 }}
|
||||
path: ${{ matrix.arch }}
|
||||
name: ${{ matrix.arch }}${{ inputs.isAot && '-aot' || '' }}
|
||||
path: ${{ env.OUTPUT }}
|
||||
|
||||
@@ -9,6 +9,10 @@ on:
|
||||
target: # windows linux macos windows-desktop
|
||||
required: true
|
||||
type: string
|
||||
isAot:
|
||||
required: false
|
||||
type: boolean
|
||||
default: false
|
||||
secrets:
|
||||
GPG_PRIVATE_KEY:
|
||||
required: true
|
||||
@@ -43,27 +47,62 @@ jobs:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v7
|
||||
|
||||
- name: Set package variables
|
||||
id: package-vars
|
||||
shell: bash
|
||||
env:
|
||||
INPUT_TARGET: ${{ inputs.target }}
|
||||
INPUT_IS_AOT: ${{ inputs.isAot }}
|
||||
run: |
|
||||
set -euo pipefail
|
||||
package_dir="v2rayN-${Target}-${Arch}"
|
||||
package_file="${package_dir}.zip"
|
||||
build_artifact_name="${{ matrix.arch }}"
|
||||
rename_suffix=""
|
||||
if [[ "$INPUT_IS_AOT" == "true" ]]; then
|
||||
build_artifact_name="${build_artifact_name}-aot"
|
||||
rename_suffix="-aot"
|
||||
fi
|
||||
if [[ "$INPUT_TARGET" == "windows-desktop" ]]; then
|
||||
rename_suffix="-desktop${rename_suffix}"
|
||||
fi
|
||||
final_package_file="${package_dir}${rename_suffix}.zip"
|
||||
|
||||
{
|
||||
echo "build_artifact_name=${build_artifact_name}"
|
||||
echo "package_dir=${package_dir}"
|
||||
echo "package_file=${package_file}"
|
||||
echo "final_package_file=${final_package_file}"
|
||||
echo "rename_suffix=${rename_suffix}"
|
||||
} >> "$GITHUB_OUTPUT"
|
||||
|
||||
- name: Restore build artifacts
|
||||
uses: actions/download-artifact@v8
|
||||
with:
|
||||
name: ${{ matrix.arch }}
|
||||
path: v2rayN-${{ env.Target }}-${{ env.Arch }}
|
||||
|
||||
name: ${{ steps.package-vars.outputs.build_artifact_name }}
|
||||
path: ${{ steps.package-vars.outputs.package_dir }}
|
||||
|
||||
- name: Get v2rayN-core-bin
|
||||
run: wget -nv -O v2rayN-$Target-$Arch.zip "https://github.com/2dust/v2rayN-core-bin/raw/refs/heads/master/v2rayN-$Target-$Arch.zip"
|
||||
|
||||
run: |
|
||||
wget -nv -O "${{ steps.package-vars.outputs.package_file }}" "https://github.com/2dust/v2rayN-core-bin/raw/refs/heads/master/v2rayN-$Target-$Arch.zip"
|
||||
|
||||
- name: Package zip archive
|
||||
run: 7z a -tZip v2rayN-$Target-$Arch.zip v2rayN-$Target-$Arch -mx1
|
||||
shell: bash
|
||||
run: |
|
||||
7z a -tZip "${{ steps.package-vars.outputs.package_file }}" "${{ steps.package-vars.outputs.package_dir }}" -mx1
|
||||
|
||||
- name: Rename package archive
|
||||
if: steps.package-vars.outputs.rename_suffix != ''
|
||||
shell: bash
|
||||
run: |
|
||||
mv "${{ steps.package-vars.outputs.package_file }}" \
|
||||
"${{ steps.package-vars.outputs.package_dir }}${{ steps.package-vars.outputs.rename_suffix }}.zip"
|
||||
|
||||
- name: Rename windows-desktop
|
||||
if: inputs.target == 'windows-desktop'
|
||||
run: mv "v2rayN-$Target-$Arch.zip" "v2rayN-$Target-$Arch-desktop.zip"
|
||||
|
||||
- name: Upload zip artifact
|
||||
uses: actions/upload-artifact@v7
|
||||
with:
|
||||
name: release-${{ inputs.target }}-${{ matrix.arch }}
|
||||
path: v2rayN*.zip
|
||||
name: release-${{ inputs.target }}-${{ matrix.arch }}${{ inputs.isAot && '-aot' || '' }}
|
||||
path: ${{ steps.package-vars.outputs.final_package_file }}
|
||||
if-no-files-found: error
|
||||
|
||||
release:
|
||||
@@ -75,7 +114,7 @@ jobs:
|
||||
uses: ./.github/workflows/upload-sign.yml
|
||||
with:
|
||||
release_tag: ${{ inputs.release_tag }}
|
||||
artifact_name: release-${{ inputs.target }}-${{ matrix.arch }}
|
||||
artifact_name: release-${{ inputs.target }}-${{ matrix.arch }}${{ inputs.isAot && '-aot' || '' }}
|
||||
file_pattern: '*.zip'
|
||||
secrets:
|
||||
GPG_PRIVATE_KEY: ${{ secrets.GPG_PRIVATE_KEY }}
|
||||
|
||||
Reference in New Issue
Block a user