Skip to content

Commit

Permalink
Merged PR 19934: Create checksum file for global tools
Browse files Browse the repository at this point in the history
Cherry-picking the checksum changes:
1. #15678
1. #17056
  • Loading branch information
daxian-dbw committed Apr 4, 2022
1 parent 284f9e4 commit 44028aa
Showing 1 changed file with 69 additions and 0 deletions.
69 changes: 69 additions & 0 deletions tools/releaseBuild/azureDevOps/templates/nuget.yml
Expand Up @@ -65,6 +65,14 @@ jobs:
artifactName: finalResults
downloadPath: '$(System.ArtifactsDirectory)'

- task: DownloadBuildArtifacts@0
displayName: 'Download PowerShell build artifacts - macosPkgResults'
inputs:
buildType: current
downloadType: single
artifactName: macosPkgResults
downloadPath: '$(System.ArtifactsDirectory)'

- powershell: 'Get-ChildItem $(System.ArtifactsDirectory) -recurse'
displayName: 'Capture downloaded artifacts'

Expand Down Expand Up @@ -188,6 +196,67 @@ jobs:
Get-ChildItem "$(System.ArtifactsDirectory)\signed\globaltool" -Recurse
displayName: Move global tool packages to subfolder and capture
- pwsh: |
$packagePath = (Join-Path $(System.ArtifactsDirectory) checksum)
New-Item $packagePath -ItemType Directory -Force > $null
$srcPaths = @("$(System.ArtifactsDirectory)\finalResults", "$(System.ArtifactsDirectory)\macosPkgResults", "$(System.ArtifactsDirectory)\signed")
$packages = Get-ChildItem -Path $srcPaths -Include *.zip, *.tar.gz, *.msi*, *.pkg, *.deb, *.rpm -Exclude "PowerShell-Symbols*" -Recurse
$packages | ForEach-Object { Copy-Item $_.FullName -Destination $packagePath -Verbose }
$packagePathList = Get-ChildItem $packagePath -Recurse | Select-Object -ExpandProperty FullName | Out-String
Write-Verbose -Verbose $packagePathList
Get-ChildItem -Path $packagePath |
ForEach-Object {
Write-Verbose -Verbose "Generating checksum file for $($_.FullName)"
$packageName = $_.Name
$hash = (Get-FileHash -Path $_.FullName -Algorithm SHA512).Hash.ToLower()
# the '*' before the packagename signifies it is a binary
"$hash *$packageName"
} |
Out-File -FilePath "$packagePath\SHA512SUMS" -Force
$fileContent = Get-Content -Path "$packagePath\SHA512SUMS" -Raw | Out-String
Write-Verbose -Verbose -Message $fileContent
Copy-Item -Path "$packagePath\SHA512SUMS" -Destination '$(System.ArtifactsDirectory)\signed\' -verbose
displayName: Generate checksum file for packages
- pwsh: |
$packagePath = (Join-Path $(System.ArtifactsDirectory) checksum_gbltool)
New-Item $packagePath -ItemType Directory -Force > $null
$srcPaths = @("$(System.ArtifactsDirectory)\signed\globaltool")
$packages = Get-ChildItem -Path $srcPaths -Include *.nupkg -Recurse
$packages | ForEach-Object { Copy-Item $_.FullName -Destination $packagePath -Verbose }
$packagePathList = Get-ChildItem $packagePath -Recurse | Select-Object -ExpandProperty FullName | Out-String
Write-Verbose -Verbose $packagePathList
$checksums = Get-ChildItem -Path $packagePath |
ForEach-Object {
Write-Verbose -Verbose "Generating checksum file for $($_.FullName)"
$packageName = $_.Name
$hash = (Get-FileHash -Path $_.FullName -Algorithm SHA512).Hash.ToLower()
# the '*' before the packagename signifies it is a binary
"$hash *$packageName"
}
$checksums | Out-File -FilePath "$packagePath\SHA512SUMS" -Force
$fileContent = Get-Content -Path "$packagePath\SHA512SUMS" -Raw | Out-String
Write-Verbose -Verbose -Message $fileContent
Copy-Item -Path "$packagePath\SHA512SUMS" -Destination '$(System.ArtifactsDirectory)\signed\globaltool\' -verbose
displayName: Generate checksum for global tools
- template: upload-final-results.yml
parameters:
artifactPath: '$(System.ArtifactsDirectory)\checksum'
artifactFilter: SHA512SUMS

- task: AzureFileCopy@4
displayName: 'Upload NuGet packages to Azure'
inputs:
Expand Down

0 comments on commit 44028aa

Please sign in to comment.