Skip to content

Commit 44028aa

Browse files
committed
Merged PR 19934: Create checksum file for global tools
Cherry-picking the checksum changes: 1. #15678 1. #17056
1 parent 284f9e4 commit 44028aa

1 file changed

Lines changed: 69 additions & 0 deletions

File tree

  • tools/releaseBuild/azureDevOps/templates

tools/releaseBuild/azureDevOps/templates/nuget.yml

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,14 @@ jobs:
6565
artifactName: finalResults
6666
downloadPath: '$(System.ArtifactsDirectory)'
6767

68+
- task: DownloadBuildArtifacts@0
69+
displayName: 'Download PowerShell build artifacts - macosPkgResults'
70+
inputs:
71+
buildType: current
72+
downloadType: single
73+
artifactName: macosPkgResults
74+
downloadPath: '$(System.ArtifactsDirectory)'
75+
6876
- powershell: 'Get-ChildItem $(System.ArtifactsDirectory) -recurse'
6977
displayName: 'Capture downloaded artifacts'
7078

@@ -188,6 +196,67 @@ jobs:
188196
Get-ChildItem "$(System.ArtifactsDirectory)\signed\globaltool" -Recurse
189197
displayName: Move global tool packages to subfolder and capture
190198
199+
- pwsh: |
200+
$packagePath = (Join-Path $(System.ArtifactsDirectory) checksum)
201+
New-Item $packagePath -ItemType Directory -Force > $null
202+
$srcPaths = @("$(System.ArtifactsDirectory)\finalResults", "$(System.ArtifactsDirectory)\macosPkgResults", "$(System.ArtifactsDirectory)\signed")
203+
204+
$packages = Get-ChildItem -Path $srcPaths -Include *.zip, *.tar.gz, *.msi*, *.pkg, *.deb, *.rpm -Exclude "PowerShell-Symbols*" -Recurse
205+
$packages | ForEach-Object { Copy-Item $_.FullName -Destination $packagePath -Verbose }
206+
207+
$packagePathList = Get-ChildItem $packagePath -Recurse | Select-Object -ExpandProperty FullName | Out-String
208+
Write-Verbose -Verbose $packagePathList
209+
210+
Get-ChildItem -Path $packagePath |
211+
ForEach-Object {
212+
Write-Verbose -Verbose "Generating checksum file for $($_.FullName)"
213+
$packageName = $_.Name
214+
$hash = (Get-FileHash -Path $_.FullName -Algorithm SHA512).Hash.ToLower()
215+
216+
# the '*' before the packagename signifies it is a binary
217+
"$hash *$packageName"
218+
} |
219+
Out-File -FilePath "$packagePath\SHA512SUMS" -Force
220+
221+
$fileContent = Get-Content -Path "$packagePath\SHA512SUMS" -Raw | Out-String
222+
Write-Verbose -Verbose -Message $fileContent
223+
224+
Copy-Item -Path "$packagePath\SHA512SUMS" -Destination '$(System.ArtifactsDirectory)\signed\' -verbose
225+
displayName: Generate checksum file for packages
226+
227+
- pwsh: |
228+
$packagePath = (Join-Path $(System.ArtifactsDirectory) checksum_gbltool)
229+
New-Item $packagePath -ItemType Directory -Force > $null
230+
$srcPaths = @("$(System.ArtifactsDirectory)\signed\globaltool")
231+
$packages = Get-ChildItem -Path $srcPaths -Include *.nupkg -Recurse
232+
$packages | ForEach-Object { Copy-Item $_.FullName -Destination $packagePath -Verbose }
233+
234+
$packagePathList = Get-ChildItem $packagePath -Recurse | Select-Object -ExpandProperty FullName | Out-String
235+
Write-Verbose -Verbose $packagePathList
236+
237+
$checksums = Get-ChildItem -Path $packagePath |
238+
ForEach-Object {
239+
Write-Verbose -Verbose "Generating checksum file for $($_.FullName)"
240+
$packageName = $_.Name
241+
$hash = (Get-FileHash -Path $_.FullName -Algorithm SHA512).Hash.ToLower()
242+
243+
# the '*' before the packagename signifies it is a binary
244+
"$hash *$packageName"
245+
}
246+
247+
$checksums | Out-File -FilePath "$packagePath\SHA512SUMS" -Force
248+
249+
$fileContent = Get-Content -Path "$packagePath\SHA512SUMS" -Raw | Out-String
250+
Write-Verbose -Verbose -Message $fileContent
251+
252+
Copy-Item -Path "$packagePath\SHA512SUMS" -Destination '$(System.ArtifactsDirectory)\signed\globaltool\' -verbose
253+
displayName: Generate checksum for global tools
254+
255+
- template: upload-final-results.yml
256+
parameters:
257+
artifactPath: '$(System.ArtifactsDirectory)\checksum'
258+
artifactFilter: SHA512SUMS
259+
191260
- task: AzureFileCopy@4
192261
displayName: 'Upload NuGet packages to Azure'
193262
inputs:

0 commit comments

Comments
 (0)