Skip to content

Commit

Permalink
Generating sha files for core tools artifacts (#3871)
Browse files Browse the repository at this point in the history
  • Loading branch information
soninaren authored and aishwaryabh committed Nov 6, 2024
1 parent 23156d3 commit a508859
Showing 1 changed file with 12 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,22 @@ param (
[string]$StagingDirectory
)

function GenerateSha([string]$filePath,[string]$artifactsPath, [string]$shaFileName)
{
$sha = (Get-FileHash $filePath).Hash.ToLower()
$shaPath = Join-Path $artifactsPath "$shaFileName.sha2"
Out-File -InputObject $sha -Encoding ascii -FilePath $shaPath -NoNewline
Write-Host "Generated sha for $filePath at $shaFileName"
}

# Get all directories in the staging directory
$directories = Get-ChildItem -Path $StagingDirectory -Directory

# Iterate over each directory and create a zip file for each one
foreach ($dir in $directories) {
# Define the zip file name (same as directory name, but with .zip extension)
$zipFile = "$StagingDirectory\$($dir.Name).zip"
$zipFileName = "$($dir.Name).zip"
$zipFile = "$StagingDirectory\$zipFileName"

# Compress the directory into the zip file
Compress-Archive -Path $dir.FullName -DestinationPath $zipFile -Force
Expand All @@ -23,6 +32,8 @@ foreach ($dir in $directories) {
} else {
Write-Host "Failed to create zip for: $($dir.FullName)"
}

GenerateSha $zipFile $StagingDirectory "$zipFileName.sha2"
}

Write-Host "All directories zipped successfully!"

0 comments on commit a508859

Please sign in to comment.