mirror of
https://github.com/actions/runner-images.git
synced 2025-12-15 06:08:07 +00:00
[Windows] Update Kotlin install (#4645)
This commit is contained in:
@@ -38,6 +38,7 @@ Export-ModuleMember -Function @(
|
||||
'Choco-Install'
|
||||
'Send-RequestToCocolateyPackages'
|
||||
'Get-LatestChocoPackageVersion'
|
||||
'Get-GitHubPackageDownloadUrl'
|
||||
'Extract-7Zip'
|
||||
'Get-CommandResult'
|
||||
'Get-WhichTool'
|
||||
|
||||
@@ -559,3 +559,30 @@ function Invoke-SBWithRetry {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function Get-GitHubPackageDownloadUrl {
|
||||
param (
|
||||
[string]$RepoOwner,
|
||||
[string]$RepoName,
|
||||
[string]$BinaryName,
|
||||
[string]$Version,
|
||||
[string]$UrlFilter,
|
||||
[boolean]$IsPrerelease = $false,
|
||||
[int]$SearchInCount = 100
|
||||
)
|
||||
|
||||
if ($Version -eq "latest") {
|
||||
$Version = "*"
|
||||
}
|
||||
$json = Invoke-RestMethod -Uri "https://api.github.com/repos/${RepoOwner}/${RepoName}/releases?per_page=${SearchInCount}"
|
||||
$versionToDownload = ($json.Where{ $_.prerelease -eq $IsPrerelease }.tag_name |
|
||||
Select-String -Pattern "\d+.\d+.\d+").Matches.Value |
|
||||
Where-Object {$_ -Like "${Version}.*" -or $_ -eq ${Version}} |
|
||||
Sort-Object {[version]$_} |
|
||||
Select-Object -Last 1
|
||||
|
||||
$UrlFilter = $UrlFilter -replace "{BinaryName}",$BinaryName -replace "{Version}",$versionToDownload
|
||||
$downloadUrl = $json.assets.browser_download_url -like $UrlFilter
|
||||
|
||||
return $downloadUrl
|
||||
}
|
||||
|
||||
@@ -4,9 +4,11 @@
|
||||
################################################################################
|
||||
|
||||
# Install Kotlin
|
||||
$url = "https://api.github.com/repos/JetBrains/kotlin/releases/latest"
|
||||
[System.String] $kotlinLatest = (Invoke-RestMethod -Uri $url).assets.browser_download_url -match "kotlin-compiler"
|
||||
$kotlinInstallerPath = Start-DownloadWithRetry -Url $kotlinLatest -Name "kotlin-compiler.zip"
|
||||
$kotlinVersion = (Get-ToolsetContent).kotlin.version
|
||||
$kotlinBinaryName = (Get-ToolsetContent).kotlin.binary_name
|
||||
|
||||
$kotlinDownloadUrl = Get-GitHubPackageDownloadUrl -RepoOwner "JetBrains" -RepoName "kotlin" -BinaryName $kotlinBinaryName -Version $kotlinVersion -UrlFilter "*{BinaryName}-{Version}.zip"
|
||||
$kotlinInstallerPath = Start-DownloadWithRetry -Url $kotlinDownloadUrl -Name "$kotlinBinaryName.zip"
|
||||
|
||||
Write-Host "Expand Kotlin archive"
|
||||
$kotlinPath = "C:\tools"
|
||||
|
||||
@@ -435,5 +435,9 @@
|
||||
},
|
||||
"postgresql": {
|
||||
"version": "14"
|
||||
},
|
||||
"kotlin": {
|
||||
"version": "latest",
|
||||
"binary_name": "kotlin-compiler"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -467,5 +467,9 @@
|
||||
},
|
||||
"postgresql": {
|
||||
"version": "14"
|
||||
},
|
||||
"kotlin": {
|
||||
"version": "latest",
|
||||
"binary_name": "kotlin-compiler"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -318,5 +318,9 @@
|
||||
},
|
||||
"postgresql": {
|
||||
"version": "14"
|
||||
},
|
||||
"kotlin": {
|
||||
"version": "latest",
|
||||
"binary_name": "kotlin-compiler"
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user