Fix nightly upload on Windows (#40843)

John Tur created

Release Notes:

- N/A

Change summary

.github/workflows/release_nightly.yml |  6 +-
script/upload-nightly.ps1             | 46 +++++-----------------------
2 files changed, 12 insertions(+), 40 deletions(-)

Detailed changes

.github/workflows/release_nightly.yml 🔗

@@ -281,11 +281,11 @@ jobs:
 
       - name: Build Zed installer
         working-directory: ${{ env.ZED_WORKSPACE }}
-        run: script/bundle-windows.ps1
+        run: script/bundle-windows.ps1 -Architecture x86_64
 
       - name: Upload Zed Nightly
         working-directory: ${{ env.ZED_WORKSPACE }}
-        run: script/upload-nightly.ps1 windows
+        run: script/upload-nightly.ps1 -Architecture x86_64
 
   bundle-windows-arm64:
     timeout-minutes: 60
@@ -328,7 +328,7 @@ jobs:
 
       - name: Upload Zed Nightly
         working-directory: ${{ env.ZED_WORKSPACE }}
-        run: script/upload-nightly.ps1 windows
+        run: script/upload-nightly.ps1 -Architecture aarch64
 
   update-nightly-tag:
     name: Update nightly tag

script/upload-nightly.ps1 🔗

@@ -1,32 +1,13 @@
+[CmdletBinding()]
+Param(
+    [Parameter()][string]$Architecture
+)
+
 # Based on the template in: https://docs.digitalocean.com/reference/api/spaces-api/
 $ErrorActionPreference = "Stop"
 . "$PSScriptRoot\lib\blob-store.ps1"
 . "$PSScriptRoot\lib\workspace.ps1"
 
-$allowedTargets = @("windows")
-
-function Test-AllowedTarget {
-    param (
-        [string]$Target
-    )
-
-    return $allowedTargets -contains $Target
-}
-
-# Process arguments
-if ($args.Count -gt 0) {
-    $target = $args[0]
-    if (Test-AllowedTarget $target) {
-        # Valid target
-    } else {
-        Write-Error "Error: Target '$target' is not allowed.`nUsage: $($MyInvocation.MyCommand.Name) [$($allowedTargets -join ', ')]"
-        exit 1
-    }
-} else {
-    Write-Error "Error: Target is not specified.`nUsage: $($MyInvocation.MyCommand.Name) [$($allowedTargets -join ', ')]"
-    exit 1
-}
-
 ParseZedWorkspace
 Write-Host "Uploading nightly for target: $target"
 
@@ -44,17 +25,8 @@ $sha | Out-File -FilePath "target/latest-sha" -NoNewline
 #     Remove-Item -Path $file.FullName
 # }
 
-switch ($target) {
-    "windows" {
-        UploadToBlobStore -BucketName $bucketName -FileToUpload $env:SETUP_PATH -BlobStoreKey "nightly/Zed-x86_64.exe"
-        UploadToBlobStore -BucketName $bucketName -FileToUpload "target/latest-sha" -BlobStoreKey "nightly/latest-sha-windows"
-
-        Remove-Item -Path $env:SETUP_PATH -ErrorAction SilentlyContinue
-        Remove-Item -Path "target/latest-sha" -ErrorAction SilentlyContinue
-    }
+UploadToBlobStore -BucketName $bucketName -FileToUpload "target/Zed-$Architecture.exe" -BlobStoreKey "nightly/Zed-$Architecture.exe"
+UploadToBlobStore -BucketName $bucketName -FileToUpload "target/latest-sha" -BlobStoreKey "nightly/latest-sha-windows"
 
-    default {
-        Write-Error "Error: Unknown target '$target'"
-        exit 1
-    }
-}
+Remove-Item -Path "target/Zed-$Architecture.exe" -ErrorAction SilentlyContinue
+Remove-Item -Path "target/latest-sha" -ErrorAction SilentlyContinue