mirror of
https://github.com/SECTL/SecScore.git
synced 2026-07-19 19:04:23 +08:00
ci(workflows): 在构建后清理 unpacked 目录以减少产物大小
- 为 Windows、macOS 和 Linux 构建作业添加清理步骤,移除 `dist/*unpacked*` 目录 - 在 dir 构建作业中,将 unpacked 目录压缩为 zip 文件后再清理原目录 - 在发布 Release 前,从 artifacts 目录中递归清理所有 unpacked 目录
This commit is contained in:
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user