Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Maven Sha256 Checksum Issue #22600

Merged
merged 1 commit into from
Oct 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ steps:
for file in $(find $jar_file_directory -type f); do
echo "Adding checksum of sha256 to file: $file"
sha256sum $file | awk '{print $1}' >$file.sha256
sha256_value=$(sha256sum $file | awk '{print $1}')
echo $sha256_value" *"$(basename "$file") >$file.sha256
echo "Added checksum of sha256 to file: $file"
done
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ steps:
displayName: 'Sign jar files: GnuPG and sha256'
inputs:
targetType: 'inline'
pwsh: true
workingDirectory: '$(Build.SourcesDirectory)'
script: |
$jar_file_directory = '${{ parameters.JarFileDirectory }}'
Expand Down Expand Up @@ -53,15 +54,22 @@ steps:
Write-Host "GnuPG signed to file: "$file_path
}

$PSDefaultParameterValues['Out-File:Encoding'] = 'utf8NoBOM'
$sha256sum_exe_path = "C:\Program Files\Git\usr\bin\sha256sum.exe"
$targeting_asc_files = Get-ChildItem $jar_file_directory -Recurse -Force -File -Name
$original_location = Get-Location
Set-Location $jar_file_directory
foreach ($file in $targeting_asc_files) {
$file_path = Join-Path $jar_file_directory -ChildPath $file
Write-Host "Adding checksum of sha256 to file: "$file_path
$file_path_sha256 = $file_path + ".sha256"
CertUtil -hashfile $file_path SHA256
CertUtil -hashfile $file_path SHA256 | find /v `"hash`" | Out-File -FilePath $file_path_sha256
Write-Host "Added checksum of sha256 to file: "$file_path
Write-Host "Adding checksum of sha256 to file: "$file
$file_path_sha256 = $file + ".sha256"
& $sha256sum_exe_path $file 1>$file_path_sha256
if ($lastExitCode -ne 0) {
Write-Host -Object "sha256sum command failed. Exitcode: $exitCode"
exit $lastExitCode
}
Write-Host "Added checksum of sha256 to file: "$file
}
Set-Location $original_location

Write-Host "GnuPG and sha256 signing to files completed."
Write-Host "Deleting GnuPG key files."
Expand Down
Loading