@@ -18,15 +18,37 @@ $ExeSource = Join-Path $BinDir "cloudsqlctl.exe"
1818$SetupSource = Join-Path $DistDir " cloudsqlctl-setup.exe"
1919
2020if (-not (Test-Path $ExeSource )) { Write-Error " Missing binary: $ExeSource " ; exit 1 }
21- if (-not (Test-Path $SetupSource )) { Write-Error " Missing installer: $SetupSource " ; exit 1 }
21+
22+ if (Test-Path $SetupSource ) {
23+ Copy-Item $SetupSource - Destination $ArtifactsDir
24+ }
25+ else {
26+ Write-Warning " Installer not found at $SetupSource . Skipping."
27+ }
2228
2329Copy-Item $ExeSource - Destination $ArtifactsDir
24- Copy-Item $SetupSource - Destination $ArtifactsDir
2530
2631# 3. Generate SHA256 Checksums
2732$ChecksumFile = Join-Path $ArtifactsDir " SHA256SUMS.txt"
28- Get-ChildItem $ArtifactsDir - Filter " *.exe" | Get-FileHash - Algorithm SHA256 | ForEach-Object {
29- " $ ( $_.Hash ) $ ( $_.Path | Split-Path - Leaf) "
33+
34+ function Get-Sha256Hash {
35+ param ($FilePath )
36+ try {
37+ $fileStream = [System.IO.File ]::OpenRead($FilePath )
38+ $hasher = [System.Security.Cryptography.SHA256 ]::Create()
39+ $hashBytes = $hasher.ComputeHash ($fileStream )
40+ $fileStream.Close ()
41+ return [BitConverter ]::ToString($hashBytes ).Replace(" -" , " " ).ToLower()
42+ }
43+ catch {
44+ Write-Error " Failed to calculate hash for ${FilePath} : $_ "
45+ exit 1
46+ }
47+ }
48+
49+ Get-ChildItem $ArtifactsDir - Filter " *.exe" | ForEach-Object {
50+ $hash = Get-Sha256Hash - FilePath $_.FullName
51+ " $hash $ ( $_.Name ) "
3052} | Out-File - Encoding ASCII $ChecksumFile
3153
3254# 4. Create Distribution Zip
0 commit comments