From a015b3ddf433338eaabee8c059dc6ede5f9f6f42 Mon Sep 17 00:00:00 2001 From: QYF-RYCBStudio Date: Sun, 9 Aug 2026 14:02:54 +0800 Subject: [PATCH] =?UTF-8?q?ci(workflow):=20=E6=B7=BB=E5=8A=A0=E5=B4=A9?= =?UTF-8?q?=E6=BA=83=E6=98=BE=E7=A4=BA=E5=92=8C=E5=90=AF=E5=8A=A8=E7=94=BB?= =?UTF-8?q?=E9=9D=A2=E6=9E=84=E5=BB=BA=E5=B7=A5=E4=BD=9C=E6=B5=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 配置了 AOT + 单文件 + 自包含发布模式 - 支持 Windows、Linux、macOS 多平台构建 - 包含 x64 和 arm64 架构支持 - 实现了构建产物汇总打包功能 - 添加了符号文件清理步骤 - 配置了 14 天产物保留策略 --- .github/workflows/build-crash-splash.yml | 204 +++++++++++++++++++++++ 1 file changed, 204 insertions(+) create mode 100644 .github/workflows/build-crash-splash.yml diff --git a/.github/workflows/build-crash-splash.yml b/.github/workflows/build-crash-splash.yml new file mode 100644 index 0000000..5e55243 --- /dev/null +++ b/.github/workflows/build-crash-splash.yml @@ -0,0 +1,204 @@ +name: Build CrashDisplayer & Splash (AOT + SingleFile + SelfContained) + +on: + workflow_dispatch: + push: + paths: + - 'MEFrpLauncherX.CrashDisplayer/**' + - 'RYCB.PML2.Splash/**' + - '.github/workflows/build-crash-splash.yml' + pull_request: + paths: + - 'MEFrpLauncherX.CrashDisplayer/**' + - 'RYCB.PML2.Splash/**' + +env: + DOTNET_VERSION: '10.0.x' + DOTNET_NOLOGO: true + DOTNET_CLI_TELEMETRY_OPTOUT: true + +jobs: + build: + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + include: + # ---------- Windows ---------- + - rid: win-x64 + os: windows-latest + app: CrashDisplayer + project: MEFrpLauncherX.CrashDisplayer/MEFrpLauncherX.CrashDisplayer.csproj + - rid: win-x64 + os: windows-latest + app: Splash + project: RYCB.PML2.Splash/RYCB.PML2.Splash/RYCB.PML2.Splash.csproj + + - rid: win-arm64 + os: windows-latest + app: CrashDisplayer + project: MEFrpLauncherX.CrashDisplayer/MEFrpLauncherX.CrashDisplayer.csproj + - rid: win-arm64 + os: windows-latest + app: Splash + project: RYCB.PML2.Splash/RYCB.PML2.Splash/RYCB.PML2.Splash.csproj + + # ---------- Linux ---------- + - rid: linux-x64 + os: ubuntu-latest + app: CrashDisplayer + project: MEFrpLauncherX.CrashDisplayer/MEFrpLauncherX.CrashDisplayer.csproj + - rid: linux-x64 + os: ubuntu-latest + app: Splash + project: RYCB.PML2.Splash/RYCB.PML2.Splash/RYCB.PML2.Splash.csproj + + - rid: linux-arm64 + os: ubuntu-24.04-arm + app: CrashDisplayer + project: MEFrpLauncherX.CrashDisplayer/MEFrpLauncherX.CrashDisplayer.csproj + - rid: linux-arm64 + os: ubuntu-24.04-arm + app: Splash + project: RYCB.PML2.Splash/RYCB.PML2.Splash/RYCB.PML2.Splash.csproj + + # ---------- macOS ---------- + - rid: osx-x64 + os: macos-latest + app: CrashDisplayer + project: MEFrpLauncherX.CrashDisplayer/MEFrpLauncherX.CrashDisplayer.csproj + - rid: osx-x64 + os: macos-latest + app: Splash + project: RYCB.PML2.Splash/RYCB.PML2.Splash/RYCB.PML2.Splash.csproj + + - rid: osx-arm64 + os: macos-latest + app: CrashDisplayer + project: MEFrpLauncherX.CrashDisplayer/MEFrpLauncherX.CrashDisplayer.csproj + - rid: osx-arm64 + os: macos-latest + app: Splash + project: RYCB.PML2.Splash/RYCB.PML2.Splash/RYCB.PML2.Splash.csproj + + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Setup .NET + uses: actions/setup-dotnet@v4 + with: + dotnet-version: ${{ env.DOTNET_VERSION }} + + - name: Install native AOT toolchain (Linux) + if: startsWith(matrix.rid, 'linux-') + run: | + sudo apt-get update -qq + sudo apt-get install -y clang zlib1g-dev + + - name: Publish (AOT + SingleFile + SelfContained) + shell: bash + run: | + set -euo pipefail + OUT="publish/${{ matrix.app }}/${{ matrix.rid }}" + mkdir -p "$OUT" + + dotnet publish "${{ matrix.project }}" \ + -c Release \ + -r "${{ matrix.rid }}" \ + --self-contained true \ + -p:PublishAot=true \ + -p:PublishSingleFile=true \ + -p:IncludeNativeLibrariesForSelfExtract=true \ + -p:EnableCompressionInSingleFile=true \ + -p:DebugType=none \ + -p:DebugSymbols=false \ + -o "$OUT" \ + --nologo -v minimal + + # Linux / macOS 给可执行文件加执行权限 + if [[ "${{ matrix.rid }}" != win-* ]]; then + find "$OUT" -type f \( -name "*.so" -o -name "*.dylib" \) -exec chmod +x {} \; 2>/dev/null || true + find "$OUT" -type f ! -name "*.*" -exec chmod +x {} \; 2>/dev/null || true + chmod +x "$OUT"/* 2>/dev/null || true + fi + + echo "===== Publish result (${{ matrix.app }} / ${{ matrix.rid }}) =====" + ls -lh "$OUT" || true + + - name: Remove debug / symbol files + shell: bash + run: | + set -euo pipefail + OUT="publish/${{ matrix.app }}/${{ matrix.rid }}" + + find "$OUT" -type f \( \ + -name "*.pdb" -o \ + -name "*.dbg" -o \ + -name "*.mdb" -o \ + -name "*.dSYM" -o \ + -name "*.ilk" -o \ + -name "*.exp" -o \ + -name "*.lib" -o \ + -name "*.map" -o \ + -name "*.xml" -o \ + -name "*.deps.json" \ + \) -print -delete 2>/dev/null || true + + find "$OUT" -type d -empty -delete 2>/dev/null || true + + echo "===== After cleanup =====" + ls -lh "$OUT" || true + echo "File count: $(find "$OUT" -type f | wc -l)" + + - name: Upload artifact + uses: actions/upload-artifact@v4 + with: + name: ${{ matrix.app }}-${{ matrix.rid }} + path: publish/${{ matrix.app }}/${{ matrix.rid }}/** + if-no-files-found: error + retention-days: 14 + + # ---------- 汇总打包,方便一次下载 ---------- + pack-all: + needs: build + runs-on: ubuntu-latest + steps: + - name: Download all artifacts + uses: actions/download-artifact@v4 + with: + path: artifacts + + - name: Pack into one zip + shell: bash + run: | + set -euo pipefail + echo "===== 当前 artifacts 结构 =====" + find artifacts -type f | sort || true + + mkdir -p release + for dir in artifacts/*; do + [ -d "$dir" ] || continue + name=$(basename "$dir") + # name 形如 CrashDisplayer-win-x64 + app="${name%%-*}" + rid="${name#*-}" + mkdir -p "release/${app}/${rid}" + cp -a "$dir"/. "release/${app}/${rid}/" + done + + echo "===== release 结构 =====" + find release -type f | sort + + cd release + zip -r -9 "../PML2-CrashDisplayer-Splash-all.zip" . + cd .. + ls -lh PML2-CrashDisplayer-Splash-all.zip + + - name: Upload single package + uses: actions/upload-artifact@v4 + with: + name: PML2-CrashDisplayer-Splash-all + path: PML2-CrashDisplayer-Splash-all.zip + if-no-files-found: error + retention-days: 14 \ No newline at end of file