Skip to repository content

tenant.openagents/omega

No repository description is available.

OpenAgents Git authority 2026-07-28T00:30:24.604Z Public web read
NIP-34 coordinate30617:7649603503856e5148d571eac2766b288a8ff1e9e35d380337a1d2b0015b4f92:omega
MaintainersHidden in public view
References2 branches ยท 1 tag
Read-only clonegit clone https://openagents.com/git/tenant.openagents/omega.git
Browse files

bundle-windows.ps1

418 lines ยท 16.3 KB ยท text
1[CmdletBinding()]
2Param(
3    [Parameter()][Alias('i')][switch]$Install,
4    [Parameter()][Alias('h')][switch]$Help,
5    [Parameter()][Alias('a')][string]$Architecture,
6    [Parameter()][string]$Name
7)
8
9. "$PSScriptRoot/lib/workspace.ps1"
10
11# https://stackoverflow.com/questions/57949031/powershell-script-stops-if-program-fails-like-bash-set-o-errexit
12$ErrorActionPreference = 'Stop'
13$PSNativeCommandUseErrorActionPreference = $true
14
15$buildSuccess = $false
16$canCodeSign = $false
17
18$OSArchitecture = switch ([System.Runtime.InteropServices.RuntimeInformation]::OSArchitecture) {
19    "X64" { "x86_64" }
20    "Arm64" { "aarch64" }
21    default { throw "Unsupported architecture" }
22}
23
24$Architecture = if ($Architecture) {
25    $Architecture
26} else {
27    $OSArchitecture
28}
29
30$CargoOutDir = "./target/$Architecture-pc-windows-msvc/release"
31
32function Get-VSArch {
33    param(
34        [string]$Arch
35    )
36
37    switch ($Arch) {
38        "x86_64" { "amd64" }
39        "aarch64" { "arm64" }
40    }
41}
42
43Push-Location
44& "C:\Program Files\Microsoft Visual Studio\2022\Community\Common7\Tools\Launch-VsDevShell.ps1" -Arch (Get-VSArch -Arch $Architecture) -HostArch (Get-VSArch -Arch $OSArchitecture)
45Pop-Location
46
47$target = "$Architecture-pc-windows-msvc"
48
49if ($Help) {
50    Write-Output "Usage: test.ps1 [-Install] [-Help]"
51    Write-Output "Build the installer for Windows.\n"
52    Write-Output "Options:"
53    Write-Output "  -Architecture, -a Which architecture to build (x86_64 or aarch64)"
54    Write-Output "  -Install, -i      Run the installer after building."
55    Write-Output "  -Help, -h         Show this help message."
56    exit 0
57}
58
59Push-Location -Path crates/zed
60$channel = Get-Content "RELEASE_CHANNEL"
61$env:ZED_RELEASE_CHANNEL = $channel
62$env:RELEASE_CHANNEL = $channel
63Pop-Location
64
65function CheckEnvironmentVariables {
66    if(-not $env:CI) {
67        return
68    }
69
70    $requiredVars = @('ZED_WORKSPACE', 'RELEASE_VERSION', 'ZED_RELEASE_CHANNEL')
71
72    foreach ($var in $requiredVars) {
73        if ([string]::IsNullOrWhiteSpace([Environment]::GetEnvironmentVariable($var))) {
74            Write-Error "$var is not set"
75            exit 1
76        }
77    }
78
79    # On PRs from forks the signing secrets are not populated,
80    # so skip code signing instead of failing, like bundle-mac does.
81    $signingVars = @(
82        'AZURE_TENANT_ID', 'AZURE_CLIENT_ID', 'AZURE_CLIENT_SECRET',
83        'ACCOUNT_NAME', 'CERT_PROFILE_NAME', 'ENDPOINT',
84        'FILE_DIGEST', 'TIMESTAMP_DIGEST', 'TIMESTAMP_SERVER'
85    )
86
87    $missingVars = @($signingVars | Where-Object { [string]::IsNullOrWhiteSpace([Environment]::GetEnvironmentVariable($_)) })
88    if ($missingVars.Count -eq 0) {
89        $script:canCodeSign = $true
90    } else {
91        Write-Host "====== WARNING ======"
92        Write-Host "One or more of the following variables are missing: $($missingVars -join ', ')"
93        Write-Host "This bundle will not be code signed"
94        Write-Host "====== WARNING ======"
95    }
96}
97
98function PrepareForBundle {
99    if (Test-Path "$innoDir") {
100        Remove-Item -Path "$innoDir" -Recurse -Force
101    }
102    New-Item -Path "$innoDir" -ItemType Directory -Force
103    Copy-Item -Path "$env:ZED_WORKSPACE\crates\zed\resources\windows\*" -Destination "$innoDir" -Recurse -Force
104    New-Item -Path "$innoDir\make_appx" -ItemType Directory -Force
105    New-Item -Path "$innoDir\appx" -ItemType Directory -Force
106    New-Item -Path "$innoDir\bin" -ItemType Directory -Force
107    New-Item -Path "$innoDir\tools" -ItemType Directory -Force
108
109    rustup target add $target
110}
111
112function GenerateLicenses {
113    . $PSScriptRoot/generate-licenses.ps1
114}
115
116function BuildZedAndItsFriends {
117    Write-Output "Building Omega and its supporting binaries, for channel: $channel"
118    # Build omega.exe, cli.exe and auto_update_helper.exe
119    cargo build --release --package zed --package cli --package auto_update_helper --target $target
120    Copy-Item -Path ".\$CargoOutDir\omega.exe" -Destination "$innoDir\Omega.exe" -Force
121    Copy-Item -Path ".\$CargoOutDir\cli.exe" -Destination "$innoDir\cli.exe" -Force
122    Copy-Item -Path ".\$CargoOutDir\auto_update_helper.exe" -Destination "$innoDir\auto_update_helper.exe" -Force
123    # Build explorer_command_injector.dll
124    switch ($channel) {
125        "stable" {
126            cargo build --release --features stable --no-default-features --package explorer_command_injector --target $target
127        }
128        "preview" {
129            cargo build --release --features preview --no-default-features --package explorer_command_injector --target $target
130        }
131        default {
132            cargo build --release --package explorer_command_injector --target $target
133        }
134    }
135    Copy-Item -Path ".\$CargoOutDir\explorer_command_injector.dll" -Destination "$innoDir\zed_explorer_command_injector.dll" -Force
136}
137
138function BuildRemoteServer {
139    Write-Output "Building remote_server for $target"
140    cargo build --release --package remote_server --target $target
141
142    # Create zipped remote server binary
143    $remoteServerSrc = (Resolve-Path ".\$CargoOutDir\remote_server.exe").Path
144
145    if ($canCodeSign) {
146        Write-Output "Code signing remote_server.exe"
147        & "$innoDir\sign.ps1" $remoteServerSrc
148    }
149
150    $remoteServerDst = "$env:ZED_WORKSPACE\target\zed-remote-server-windows-$Architecture.zip"
151    Write-Output "Compressing remote_server to $remoteServerDst"
152    Compress-Archive -Path $remoteServerSrc -DestinationPath $remoteServerDst -Force
153
154    Write-Output "Remote server compressed successfully"
155}
156
157function ZipZedAndItsFriendsDebug {
158    $items = @(
159        ".\$CargoOutDir\zed.pdb",
160        ".\$CargoOutDir\cli.pdb",
161        ".\$CargoOutDir\auto_update_helper.pdb",
162        ".\$CargoOutDir\explorer_command_injector.pdb",
163        ".\$CargoOutDir\remote_server.pdb"
164    )
165
166    Compress-Archive -Path $items -DestinationPath ".\$CargoOutDir\zed-$env:RELEASE_VERSION-$env:ZED_RELEASE_CHANNEL.dbg.zip" -Force
167}
168
169
170function UploadToSentry {
171    if (-not (Get-Command "sentry-cli" -ErrorAction SilentlyContinue)) {
172        Write-Output "sentry-cli not found. skipping sentry upload."
173        Write-Output "install with: 'winget install -e --id=Sentry.sentry-cli'"
174        return
175    }
176    if ([string]::IsNullOrWhiteSpace($env:SENTRY_AUTH_TOKEN)) {
177        Write-Output "missing SENTRY_AUTH_TOKEN. skipping sentry upload."
178        return
179    }
180    Write-Output "Uploading zed debug symbols to sentry..."
181    for ($i = 1; $i -le 3; $i++) {
182        try {
183            sentry-cli debug-files upload --include-sources --wait -p zed -o zed-dev $CargoOutDir
184            break
185        }
186        catch {
187            Write-Output "Sentry upload attempt $i failed: $_"
188            if ($i -eq 3) {
189                Write-Output "All sentry upload attempts failed"
190                throw
191            }
192            Start-Sleep -Seconds 2
193        }
194    }
195}
196
197function MakeAppx {
198    switch ($channel) {
199        "stable" {
200            $manifestFile = "$env:ZED_WORKSPACE\crates\explorer_command_injector\AppxManifest.xml"
201        }
202        "preview" {
203            $manifestFile = "$env:ZED_WORKSPACE\crates\explorer_command_injector\AppxManifest-Preview.xml"
204        }
205        default {
206            $manifestFile = "$env:ZED_WORKSPACE\crates\explorer_command_injector\AppxManifest-Nightly.xml"
207        }
208    }
209    Copy-Item -Path "$manifestFile" -Destination "$innoDir\make_appx\AppxManifest.xml"
210    # Add makeAppx.exe to Path
211    $sdk = "C:\Program Files (x86)\Windows Kits\10\bin\10.0.26100.0\x64"
212    $env:Path += ';' + $sdk
213    makeAppx.exe pack /d "$innoDir\make_appx" /p "$innoDir\zed_explorer_command_injector.appx" /nv
214}
215
216function SignZedAndItsFriends {
217    if (-not $canCodeSign) {
218        return
219    }
220
221    $files = "$innoDir\Omega.exe,$innoDir\cli.exe,$innoDir\auto_update_helper.exe,$innoDir\zed_explorer_command_injector.dll,$innoDir\zed_explorer_command_injector.appx"
222    & "$innoDir\sign.ps1" $files
223}
224
225function DownloadAMDGpuServices {
226    # If you update the AGS SDK version, please also update the version in `crates/gpui/src/platform/windows/directx_renderer.rs`
227    $url = "https://codeload.github.com/GPUOpen-LibrariesAndSDKs/AGS_SDK/zip/refs/tags/v6.3.0"
228    $zipPath = ".\AGS_SDK_v6.3.0.zip"
229    # Download the AGS SDK zip file
230    Invoke-WebRequest -Uri $url -OutFile $zipPath
231    # Extract the AGS SDK zip file
232    Expand-Archive -Path $zipPath -DestinationPath "." -Force
233}
234
235function DownloadConpty {
236    $url = "https://github.com/microsoft/terminal/releases/download/v1.23.13503.0/Microsoft.Windows.Console.ConPTY.1.23.251216003.nupkg"
237    $zipPath = ".\Microsoft.Windows.Console.ConPTY.1.23.251216003.nupkg"
238    Invoke-WebRequest -Uri $url -OutFile $zipPath
239    Expand-Archive -Path $zipPath -DestinationPath ".\conpty" -Force
240}
241
242function CollectFiles {
243    Move-Item -Path "$innoDir\zed_explorer_command_injector.appx" -Destination "$innoDir\appx\zed_explorer_command_injector.appx" -Force
244    Move-Item -Path "$innoDir\zed_explorer_command_injector.dll" -Destination "$innoDir\appx\zed_explorer_command_injector.dll" -Force
245    Move-Item -Path "$innoDir\cli.exe" -Destination "$innoDir\bin\omega.exe" -Force
246    Move-Item -Path "$innoDir\zed.sh" -Destination "$innoDir\bin\omega" -Force
247    Move-Item -Path "$innoDir\auto_update_helper.exe" -Destination "$innoDir\tools\auto_update_helper.exe" -Force
248    if($Architecture -eq "aarch64") {
249        New-Item -Type Directory -Path "$innoDir\arm64" -Force
250        Move-Item -Path ".\conpty\build\native\runtimes\arm64\OpenConsole.exe" -Destination "$innoDir\arm64\OpenConsole.exe" -Force
251        Move-Item -Path ".\conpty\runtimes\win-arm64\native\conpty.dll" -Destination "$innoDir\conpty.dll" -Force
252    }
253    else {
254        New-Item -Type Directory -Path "$innoDir\x64" -Force
255        New-Item -Type Directory -Path "$innoDir\arm64" -Force
256        Move-Item -Path ".\AGS_SDK-6.3.0\ags_lib\lib\amd_ags_x64.dll" -Destination "$innoDir\amd_ags_x64.dll" -Force
257        Move-Item -Path ".\conpty\build\native\runtimes\x64\OpenConsole.exe" -Destination "$innoDir\x64\OpenConsole.exe" -Force
258        Move-Item -Path ".\conpty\build\native\runtimes\arm64\OpenConsole.exe" -Destination "$innoDir\arm64\OpenConsole.exe" -Force
259        Move-Item -Path ".\conpty\runtimes\win-x64\native\conpty.dll" -Destination "$innoDir\conpty.dll" -Force
260    }
261}
262
263function BuildInstaller {
264    $issFilePath = "$innoDir\zed.iss"
265    switch ($channel) {
266        "stable" {
267            $appId = "{{BB00F414-2B2F-4AF0-8896-9A2D46EF314D}"
268            $appIconName = "app-icon"
269            $appName = "Omega"
270            $appDisplayName = "Omega"
271            $appSetupName = "Omega-$Architecture"
272            # The mutex name here should match the mutex name in crates\zed\src\zed\windows_only_instance.rs
273            $appMutex = "OpenAgents-Omega-Instance-Mutex"
274            $appExeName = "Omega"
275            $regValueName = "Omega"
276            $appUserId = "OpenAgents.Omega"
277            $appShellNameShort = "&Omega"
278            $appAppxFullName = "OpenAgents.Omega_1.0.0.0_neutral__japxn1gcva8rg"
279            $appScheme = "omega"
280        }
281        "preview" {
282            $appId = "{{BCEF3CCF-E44E-4428-BDAE-6CDE07B002DC}"
283            $appIconName = "app-icon-preview"
284            $appName = "Omega RC"
285            $appDisplayName = "Omega RC"
286            $appSetupName = "Omega-RC-$Architecture"
287            # The mutex name here should match the mutex name in crates\zed\src\zed\windows_only_instance.rs
288            $appMutex = "OpenAgents-Omega-RC-Instance-Mutex"
289            $appExeName = "Omega"
290            $regValueName = "OmegaRC"
291            $appUserId = "OpenAgents.Omega.RC"
292            $appShellNameShort = "&Omega RC"
293            $appAppxFullName = "OpenAgents.Omega.RC_1.0.0.0_neutral__japxn1gcva8rg"
294            $appScheme = "omega-rc"
295        }
296        "nightly" {
297            $appId = "{{E25A8B18-9687-44BC-B2E5-C0301AFB7E22}"
298            $appIconName = "app-icon-nightly"
299            $appName = "Omega Nightly"
300            $appDisplayName = "Omega Nightly"
301            $appSetupName = "Omega-Nightly-$Architecture"
302            # The mutex name here should match the mutex name in crates\zed\src\zed\windows_only_instance.rs
303            $appMutex = "OpenAgents-Omega-Nightly-Instance-Mutex"
304            $appExeName = "Omega"
305            $regValueName = "OmegaNightly"
306            $appUserId = "OpenAgents.Omega.Nightly"
307            $appShellNameShort = "&Omega Nightly"
308            $appAppxFullName = "OpenAgents.Omega.Nightly_1.0.0.0_neutral__japxn1gcva8rg"
309            $appScheme = "omega-nightly"
310        }
311        "dev" {
312            $appId = "{{572EDAAB-DB62-4818-B734-7AB3B6F4DB11}"
313            $appIconName = "app-icon-dev"
314            $appName = "Omega Dev"
315            $appDisplayName = "Omega Dev"
316            $appSetupName = "Omega-Dev-$Architecture"
317            # The mutex name here should match the mutex name in crates\zed\src\zed\windows_only_instance.rs
318            $appMutex = "OpenAgents-Omega-Dev-Instance-Mutex"
319            $appExeName = "Omega"
320            $regValueName = "OmegaDev"
321            $appUserId = "OpenAgents.Omega.Dev"
322            $appShellNameShort = "&Omega Dev"
323            $appAppxFullName = "OpenAgents.Omega.Dev_1.0.0.0_neutral__japxn1gcva8rg"
324            $appScheme = "omega-dev"
325        }
326        default {
327            Write-Error "can't bundle installer for $channel."
328            exit 1
329        }
330    }
331
332    # Windows runner 2022 default has iscc in PATH, https://github.com/actions/runner-images/blob/main/images/windows/Windows2022-Readme.md
333    # Currently, we are using Windows 2022 runner.
334    # Windows runner 2025 doesn't have iscc in PATH for now, https://github.com/actions/runner-images/issues/11228
335    $innoSetupPath = "C:\Program Files (x86)\Inno Setup 6\ISCC.exe"
336
337    $definitions = @{
338        "AppId"          = $appId
339        "AppIconName"    = $appIconName
340        "OutputDir"      = "$env:ZED_WORKSPACE\target"
341        "AppSetupName"   = $appSetupName
342        "AppName"        = $appName
343        "AppDisplayName" = $appDisplayName
344        "RegValueName"   = $regValueName
345        "AppMutex"       = $appMutex
346        "AppExeName"     = $appExeName
347        "ResourcesDir"   = "$innoDir"
348        "ShellNameShort" = $appShellNameShort
349        "AppUserId"      = $appUserId
350        "Version"        = "$env:RELEASE_VERSION"
351        "SourceDir"      = "$env:ZED_WORKSPACE"
352        "AppxFullName"   = $appAppxFullName
353        "AppScheme"      = $appScheme
354    }
355
356    $defs = @()
357    foreach ($key in $definitions.Keys) {
358        $defs += "/d$key=`"$($definitions[$key])`""
359    }
360
361    $innoArgs = @($issFilePath) + $defs
362    if($canCodeSign) {
363        # Checked by zed.iss to decide whether to sign the installer.
364        $env:ZED_SIGN_BUNDLE = "1"
365        $signTool = "powershell.exe -ExecutionPolicy Bypass -File $innoDir\sign.ps1 `$f"
366        $innoArgs += "/sDefaultsign=`"$signTool`""
367    }
368
369    # Execute Inno Setup
370    Write-Host "๐Ÿš€ Running Inno Setup: $innoSetupPath $innoArgs"
371    $process = Start-Process -FilePath $innoSetupPath -ArgumentList $innoArgs -NoNewWindow -Wait -PassThru
372
373    if ($process.ExitCode -eq 0) {
374        Write-Host "โœ… Inno Setup successfully compiled the installer"
375        Write-Output "SETUP_PATH=target/$appSetupName.exe" >> $env:GITHUB_ENV
376        $script:buildSuccess = $true
377    }
378    else {
379        Write-Host "โŒ Inno Setup failed: $($process.ExitCode)"
380        $script:buildSuccess = $false
381    }
382}
383
384ParseZedWorkspace
385$innoDir = "$env:ZED_WORKSPACE\inno\$Architecture"
386$debugArchive = "$CargoOutDir\zed-$env:RELEASE_VERSION-$env:ZED_RELEASE_CHANNEL.dbg.zip"
387$debugStoreKey = "$env:ZED_RELEASE_CHANNEL/zed-$env:RELEASE_VERSION-$env:ZED_RELEASE_CHANNEL.dbg.zip"
388
389CheckEnvironmentVariables
390PrepareForBundle
391GenerateLicenses
392BuildZedAndItsFriends
393BuildRemoteServer
394MakeAppx
395SignZedAndItsFriends
396ZipZedAndItsFriendsDebug
397DownloadAMDGpuServices
398DownloadConpty
399CollectFiles
400BuildInstaller
401
402if($env:CI) {
403    UploadToSentry
404}
405
406if ($buildSuccess) {
407    Write-Output "Build successful"
408    if ($Install) {
409        Write-Output "Installing Zed..."
410        Start-Process -FilePath "$env:ZED_WORKSPACE/target/ZedEditorUserSetup-x64-$env:RELEASE_VERSION.exe"
411    }
412    exit 0
413}
414else {
415    Write-Output "Build failed"
416    exit 1
417}
418
Served at tenant.openagents/omega Member data and write actions are omitted.