Skip to content

armgit / zed

Public Imported from GitHub
0

Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.

Mimic macOS bundling behavior for Windows builds (#61180)

Kirill Bulatovdde45ff09276
diff --git a/crates/zed/resources/windows/zed.iss b/crates/zed/resources/windows/zed.iss
index 9df6d3b2282..b0481daa6a1 100644
--- a/crates/zed/resources/windows/zed.iss
+++ b/crates/zed/resources/windows/zed.iss
@@ -31,7 +31,7 @@ WizardStyle=modern
CloseApplications=force
-#if GetEnv("CI") != ""
+#if GetEnv("ZED_SIGN_BUNDLE") != ""
SignTool=Defaultsign
#endif
diff --git a/script/bundle-windows.ps1 b/script/bundle-windows.ps1
index 53527e1b8f9..99b2858f8e6 100644
--- a/script/bundle-windows.ps1
+++ b/script/bundle-windows.ps1
@@ -13,6 +13,7 @@ $ErrorActionPreference = 'Stop'
$PSNativeCommandUseErrorActionPreference = $true
$buildSuccess = $false
+$canCodeSign = $false
$OSArchitecture = switch ([System.Runtime.InteropServices.RuntimeInformation]::OSArchitecture) {
"X64" { "x86_64" }
@@ -66,19 +67,32 @@ function CheckEnvironmentVariables {
return
}
- $requiredVars = @(
- 'ZED_WORKSPACE', 'RELEASE_VERSION', 'ZED_RELEASE_CHANNEL',
- 'AZURE_TENANT_ID', 'AZURE_CLIENT_ID', 'AZURE_CLIENT_SECRET',
- 'ACCOUNT_NAME', 'CERT_PROFILE_NAME', 'ENDPOINT',
- 'FILE_DIGEST', 'TIMESTAMP_DIGEST', 'TIMESTAMP_SERVER'
- )
+ $requiredVars = @('ZED_WORKSPACE', 'RELEASE_VERSION', 'ZED_RELEASE_CHANNEL')
foreach ($var in $requiredVars) {
- if (-not (Test-Path "env:$var")) {
+ if ([string]::IsNullOrWhiteSpace([Environment]::GetEnvironmentVariable($var))) {
Write-Error "$var is not set"
exit 1
}
}
+
+ # On PRs from forks the signing secrets are not populated,
+ # so skip code signing instead of failing, like bundle-mac does.
+ $signingVars = @(
+ 'AZURE_TENANT_ID', 'AZURE_CLIENT_ID', 'AZURE_CLIENT_SECRET',
+ 'ACCOUNT_NAME', 'CERT_PROFILE_NAME', 'ENDPOINT',
+ 'FILE_DIGEST', 'TIMESTAMP_DIGEST', 'TIMESTAMP_SERVER'
+ )
+
+ $missingVars = @($signingVars | Where-Object { [string]::IsNullOrWhiteSpace([Environment]::GetEnvironmentVariable($_)) })
+ if ($missingVars.Count -eq 0) {
+ $script:canCodeSign = $true
+ } else {
+ Write-Host "====== WARNING ======"
+ Write-Host "One or more of the following variables are missing: $($missingVars -join ', ')"
+ Write-Host "This bundle will not be code signed"
+ Write-Host "====== WARNING ======"
+ }
}
function PrepareForBundle {
@@ -128,7 +142,7 @@ function BuildRemoteServer {
# Create zipped remote server binary
$remoteServerSrc = (Resolve-Path ".\$CargoOutDir\remote_server.exe").Path
- if ($env:CI) {
+ if ($canCodeSign) {
Write-Output "Code signing remote_server.exe"
& "$innoDir\sign.ps1" $remoteServerSrc
}
@@ -159,7 +173,7 @@ function UploadToSentry {
Write-Output "install with: 'winget install -e --id=Sentry.sentry-cli'"
return
}
- if (-not (Test-Path "env:SENTRY_AUTH_TOKEN")) {
+ if ([string]::IsNullOrWhiteSpace($env:SENTRY_AUTH_TOKEN)) {
Write-Output "missing SENTRY_AUTH_TOKEN. skipping sentry upload."
return
}
@@ -200,7 +214,7 @@ function MakeAppx {
}
function SignZedAndItsFriends {
- if (-not $env:CI) {
+ if (-not $canCodeSign) {
return
}
@@ -340,7 +354,9 @@ function BuildInstaller {
}
$innoArgs = @($issFilePath) + $defs
- if($env:CI) {
+ if($canCodeSign) {
+ # Checked by zed.iss to decide whether to sign the installer.
+ $env:ZED_SIGN_BUNDLE = "1"
$signTool = "powershell.exe -ExecutionPolicy Bypass -File $innoDir\sign.ps1 `$f"
$innoArgs += "/sDefaultsign=`"$signTool`""
}