From 1e6b61db8570811cc7d693cc99b23156a8dced07 Mon Sep 17 00:00:00 2001 From: lincube Date: Mon, 20 Apr 2026 08:55:45 +0800 Subject: [PATCH] fix: normalize PEM line endings in signing key validation --- .github/workflows/release.yml | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index fd28a6d..725a662 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -372,8 +372,12 @@ jobs: Set-Content -Path $publicKeyPath -Value $derivedPublicKey -NoNewline $repoPublicKeyPath = "LanMountainDesktop.Launcher/Assets/public-key.pem" - $repoPublicKey = (Get-Content -Path $repoPublicKeyPath -Raw).Trim() - if ($repoPublicKey -ne $derivedPublicKey.Trim()) { + $repoPublicKey = (Get-Content -Path $repoPublicKeyPath -Raw) + $normalizePem = { + param([string]$pem) + return (($pem -replace "`r`n", "`n" -replace "`r", "`n").Trim()) + } + if (& $normalizePem $repoPublicKey -ne (& $normalizePem $derivedPublicKey)) { Write-Error "Configured signing private key does not match $repoPublicKeyPath. Keep keypair consistent before publishing." exit 1 } @@ -658,8 +662,12 @@ jobs: Set-Content -Path $publicKeyPath -Value $derivedPublicKey -NoNewline $repoPublicKeyPath = "LanMountainDesktop.Launcher/Assets/public-key.pem" - $repoPublicKey = (Get-Content -Path $repoPublicKeyPath -Raw).Trim() - if ($repoPublicKey -ne $derivedPublicKey.Trim()) { + $repoPublicKey = (Get-Content -Path $repoPublicKeyPath -Raw) + $normalizePem = { + param([string]$pem) + return (($pem -replace "`r`n", "`n" -replace "`r", "`n").Trim()) + } + if (& $normalizePem $repoPublicKey -ne (& $normalizePem $derivedPublicKey)) { Write-Error "Configured signing private key does not match $repoPublicKeyPath. Keep keypair consistent before publishing." exit 1 }