1[CmdletBinding()]
 2Param(
 3    [Parameter()][string]$Architecture
 4)
 5
 6# Based on the template in: https://docs.digitalocean.com/reference/api/spaces-api/
 7$ErrorActionPreference = "Stop"
 8. "$PSScriptRoot\lib\blob-store.ps1"
 9. "$PSScriptRoot\lib\workspace.ps1"
10
11ParseZedWorkspace
12Write-Host "Uploading nightly for target: $target"
13
14$bucketName = "zed-nightly-host"
15
16# Get current git SHA
17$sha = git rev-parse HEAD
18$sha | Out-File -FilePath "target/latest-sha" -NoNewline
19
20# TODO:
21# Upload remote server files
22# $remoteServerFiles = Get-ChildItem -Path "target" -Filter "zed-remote-server-*.gz" -Recurse -File
23# foreach ($file in $remoteServerFiles) {
24#     Upload-ToBlobStore -BucketName $bucketName -FileToUpload $file.FullName -BlobStoreKey "nightly/$($file.Name)"
25#     Remove-Item -Path $file.FullName
26# }
27
28UploadToBlobStore -BucketName $bucketName -FileToUpload "target/Zed-$Architecture.exe" -BlobStoreKey "nightly/Zed-$Architecture.exe"
29UploadToBlobStore -BucketName $bucketName -FileToUpload "target/latest-sha" -BlobStoreKey "nightly/latest-sha-windows"
30
31Remove-Item -Path "target/Zed-$Architecture.exe" -ErrorAction SilentlyContinue
32Remove-Item -Path "target/latest-sha" -ErrorAction SilentlyContinue