提交记录修改docs/ci-cd.md+2 −0看文件
修改scripts/package-windows.ps1+3 −2看文件
修改scripts/windows-common.ps1+7 −2看文件
| @@ -16,6 +16,8 @@ Cage 的日常推送会检查 macOS、Windows 和 Linux,并保存测试安装 | ||
| 16 | 16 | |
| 17 | 17 | Windows 的 NSIS 文件匹配按打包工具所在平台使用路径分隔符,Windows runner 和其他主机上的交叉打包共用一份安装脚本。Linux 原生验收在 Ubuntu 22.04 托管 runner 上的一次性 Debian 12 容器内以普通用户运行;Ubuntu 24.04 的宿主策略会额外限制容器用户的 UID 映射。容器放开 bubblewrap 所需的外层 AppArmor、seccomp 和挂载限制,并先验证命名空间可用,应用自身的 WebKit 沙箱保持开启。这些容器设置不进入发行包,也不改变用户主机的安全配置。 |
| 18 | 18 | |
| 19 | 新增:Windows 配套的 QEMU 源码归档使用固定提交、换行设置和 tar 权限,生成后核对固定摘要再写入缓存,避免开发者或 runner 的 Git 默认设置改变归档内容。该校验在安装器压缩前执行,摘要不符时立即停止。 | |
| 20 | 新增: | |
| 19 | 21 | 官网文件的普通推送只做检查和构建。官网部署随显式发布流程完成,也可以由维护者明确运行网站部署工作流。 |
| 20 | 22 | |
| 21 | 23 | ## 明确发版后的自动流程 |
| @@ -42,6 +42,9 @@ if ($Release) { | ||
| 42 | 42 | if ($webview.Status -ne 'Valid' -or $webview.SignerCertificate.Subject -notmatch 'O=Microsoft Corporation') { throw 'WebView2 installer must have a valid Microsoft signature.' } |
| 43 | 43 | } |
| 44 | 44 | New-Item -ItemType Directory -Path $OutputDirectory -Force | Out-Null |
| 45 | 新增:# Verify source material before the expensive installer compression. | |
| 46 | 新增:$dependencies = Get-Content -LiteralPath (Join-Path $repository 'packaging/windows/dependencies.json') -Raw | ConvertFrom-Json | |
| 47 | 新增:$qemuTar = Get-VerifiedGitArchive $dependencies.qemuSource (Join-Path $repository '_output/windows-deps') | |
| 45 | 48 | $suffix = if ($Release) { '' } else { '-unsigned' } |
| 46 | 49 | $artifact = Join-Path $OutputDirectory "Cage-$version-windows-amd64-setup$suffix.exe" |
| 47 | 50 | $manifest = Join-Path $OutputDirectory 'uninstall-files.nsh' |
| @@ -66,13 +69,11 @@ if ($Release) { Sign-CageFile $artifact $signTool } | ||
| 66 | 69 | if ((Get-Item -LiteralPath $artifact).Length -gt 512MB) { throw 'Installer exceeds the application updater 512 MiB limit.' } |
| 67 | 70 | |
| 68 | 71 | # Source materials travel beside the binary, not inside the application directory. |
| 69 | 删除:$dependencies = Get-Content -LiteralPath (Join-Path $repository 'packaging/windows/dependencies.json') -Raw | ConvertFrom-Json | |
| 70 | 72 | $coreSource = Join-Path $OutputDirectory "mihomo-$($dependencies.mihomo.version)-source.tar.gz" |
| 71 | 73 | $verifiedCoreSource = Get-VerifiedDependency $dependencies.mihomoSource (Join-Path $repository '_output/windows-deps') |
| 72 | 74 | Copy-Item -LiteralPath $verifiedCoreSource -Destination $coreSource -Force |
| 73 | 75 | Invoke-BuildTool $sevenZip @('t', '-bso0', '-bsp0', $coreSource) |
| 74 | 76 | $releaseFiles = @($artifact, $coreSource) |
| 75 | 删除:$qemuTar = Get-VerifiedGitArchive $dependencies.qemuSource (Join-Path $repository '_output/windows-deps') | |
| 76 | 77 | $qemuSource = Join-Path $OutputDirectory ($dependencies.qemuSource.file + '.gz') |
| 77 | 78 | if (Test-Path -LiteralPath $qemuSource) { Remove-Item -LiteralPath $qemuSource } |
| 78 | 79 | Invoke-BuildTool $sevenZip @('a', '-tgzip', '-mx=9', '-bso0', '-bsp0', $qemuSource, $qemuTar) |
| @@ -62,14 +62,19 @@ function Get-VerifiedGitArchive { | ||
| 62 | 62 | Invoke-BuildTool $git @('--git-dir', $checkout, 'fetch', '--depth=1', $Dependency.repository, $Dependency.commit) |
| 63 | 63 | $actualCommit = & $git '--git-dir' $checkout 'rev-parse' 'FETCH_HEAD' |
| 64 | 64 | if ($LASTEXITCODE -ne 0 -or $actualCommit -ne $Dependency.commit) { throw 'Fetched source commit does not match the pinned QEMU build.' } |
| 65 | 删除: Invoke-BuildTool $git @('--git-dir', $checkout, 'archive', '--format=tar', "--prefix=$($Dependency.prefix)", "--output=$partial", $Dependency.commit) | |
| 65 | 新增: # Git for Windows defaults can change archive bytes. Keep the | |
| 66 | 新增: # pinned source identical to the reviewed POSIX-generated archive. | |
| 67 | 新增: Invoke-BuildTool $git @('--git-dir', $checkout, '-c', 'core.autocrlf=false', '-c', 'tar.umask=0002', 'archive', '--format=tar', "--prefix=$($Dependency.prefix)", "--output=$partial", $Dependency.commit) | |
| 68 | 新增: $actualHash = (Get-FileHash -LiteralPath $partial -Algorithm SHA256).Hash.ToLowerInvariant() | |
| 69 | 新增: if ($actualHash -ne $Dependency.hash) { throw "Source archive checksum mismatch: $($Dependency.file); expected $($Dependency.hash), actual $actualHash" } | |
| 66 | 70 | Move-Item -LiteralPath $partial -Destination $archive |
| 67 | 71 | } finally { |
| 68 | 72 | Remove-Item -LiteralPath $checkout -Recurse -Force -ErrorAction SilentlyContinue |
| 69 | 73 | Remove-Item -LiteralPath $partial -Force -ErrorAction SilentlyContinue |
| 70 | 74 | } |
| 71 | 75 | } |
| 72 | 删除: if ((Get-FileHash -LiteralPath $archive -Algorithm SHA256).Hash -ne $Dependency.hash) { throw "Source archive checksum mismatch: $($Dependency.file)" } | |
| 76 | 新增: $actualHash = (Get-FileHash -LiteralPath $archive -Algorithm SHA256).Hash.ToLowerInvariant() | |
| 77 | 新增: if ($actualHash -ne $Dependency.hash) { throw "Source archive checksum mismatch: $($Dependency.file); expected $($Dependency.hash), actual $actualHash. Remove the cached file and retry." } | |
| 73 | 78 | return $archive |
| 74 | 79 | } |
| 75 | 80 | |

