[Windows] Rename and refactor downloading function (#8906)

This commit is contained in:
Vasilii Polikarpov
2023-11-29 13:02:29 +01:00
committed by GitHub
parent bfe32a2b12
commit 7dba8776df
32 changed files with 105 additions and 130 deletions

View File

@@ -11,17 +11,17 @@ $kotlinDownloadUrl = Resolve-GithubReleaseAssetUrl `
-Repo "JetBrains/kotlin" `
-Version $kotlinVersion `
-Asset "kotlin-compiler-*.zip"
$kotlinInstallerPath = Start-DownloadWithRetry -Url $kotlinDownloadUrl -Name "kotlin-compiler.zip"
$kotlinArchivePath = Invoke-DownloadWithRetry $kotlinDownloadUrl
#region Supply chain security
$fileHash = (Get-FileHash -Path $kotlinInstallerPath -Algorithm SHA256).Hash
$fileHash = (Get-FileHash -Path $kotlinArchivePath -Algorithm SHA256).Hash
$externalHash = Get-HashFromGitHubReleaseBody -RepoOwner "JetBrains" -RepoName "kotlin" -FileName "$kotlinBinaryName-*.zip" -Version $kotlinVersion -WordNumber 2
Use-ChecksumComparison $fileHash $externalHash
#endregion
Write-Host "Expand Kotlin archive"
$kotlinPath = "C:\tools"
Expand-7ZipArchive -Path $kotlinInstallerPath -DestinationPath $kotlinPath
Expand-7ZipArchive -Path $kotlinArchivePath -DestinationPath $kotlinPath
# Add to PATH
Add-MachinePathItem "$kotlinPath\kotlinc\bin"