From 64037958393df615b9433d8dcbb97949f4a3ebd0 Mon Sep 17 00:00:00 2001 From: Fox_block Date: Fri, 23 Jan 2026 13:17:16 +0800 Subject: [PATCH] =?UTF-8?q?ci(workflows):=20=E5=9C=A8=E6=9E=84=E5=BB=BA?= =?UTF-8?q?=E5=90=8E=E6=B8=85=E7=90=86=20unpacked=20=E7=9B=AE=E5=BD=95?= =?UTF-8?q?=E4=BB=A5=E5=87=8F=E5=B0=91=E4=BA=A7=E7=89=A9=E5=A4=A7=E5=B0=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 为 Windows、macOS 和 Linux 构建作业添加清理步骤,移除 `dist/*unpacked*` 目录 - 在 dir 构建作业中,将 unpacked 目录压缩为 zip 文件后再清理原目录 - 在发布 Release 前,从 artifacts 目录中递归清理所有 unpacked 目录 --- .github/workflows/build.yml | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 3869537..1c1040f 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -83,6 +83,15 @@ jobs: - name: 构建(Windows) run: pnpm build:win + - name: 清理 unpacked 目录 + shell: pwsh + run: | + if (Test-Path dist) { + Get-ChildItem -Path dist -Directory -ErrorAction SilentlyContinue | + Where-Object { $_.Name -like '*unpacked*' } | + ForEach-Object { Remove-Item -Recurse -Force $_.FullName } + } + - uses: actions/upload-artifact@v4 with: name: dist-win @@ -112,6 +121,9 @@ jobs: - name: 构建(macOS) run: pnpm -s build:mac + - name: 清理 unpacked 目录 + run: rm -rf dist/*unpacked* + - uses: actions/upload-artifact@v4 with: name: dist-mac @@ -141,6 +153,9 @@ jobs: - name: 构建(Linux) run: pnpm -s build:linux + - name: 清理 unpacked 目录 + run: rm -rf dist/*unpacked* + - uses: actions/upload-artifact@v4 with: name: dist-linux @@ -170,6 +185,20 @@ jobs: - name: 构建(dir) run: pnpm -s build:unpack + - name: 打包并移除 unpacked 目录 + shell: pwsh + run: | + if (Test-Path dist) { + $dirs = Get-ChildItem -Path dist -Directory -ErrorAction SilentlyContinue | Where-Object { $_.Name -like '*unpacked*' } + foreach ($d in $dirs) { + $zipBase = ($d.Name -replace 'unpacked', 'dir') + $zipPath = Join-Path dist "$zipBase.zip" + if (Test-Path $zipPath) { Remove-Item -Force $zipPath } + Compress-Archive -Path (Join-Path $d.FullName '*') -DestinationPath $zipPath -Force + Remove-Item -Recurse -Force $d.FullName + } + } + - uses: actions/upload-artifact@v4 with: name: dist-unpack @@ -184,6 +213,12 @@ jobs: with: path: artifacts + - name: 清理 unpacked 目录 + run: | + if [ -d artifacts ]; then + find artifacts -type d -name '*unpacked*' -prune -exec rm -rf {} + + fi + - name: 发布 Release uses: softprops/action-gh-release@v2 with: