mirror of
https://github.com/actions/runner-images.git
synced 2025-12-14 22:05:17 +00:00
[Windows] Cleanup various scripts (#8942)
* Use Resolve-GithubReleaseAssetUrl more widely * Add the Get-ChecksumFromUrl function * Sort exported functions and add docs * Remove alias and fix typo * Fix kind checksum url and syntax * Fix checksums url for gh cli and msys2 * [Windows] Cleanup various scripts * Add spaces after type specifications * Rename the Take-Part function
This commit is contained in:
committed by
GitHub
parent
ed911223ab
commit
5ed2615017
@@ -1,28 +1,28 @@
|
||||
function Get-ToolcacheGoVersions {
|
||||
$toolcachePath = Join-Path $env:AGENT_TOOLSDIRECTORY "Go"
|
||||
return Get-ChildItem $toolcachePath -Name | Sort-Object { [Version]$_ }
|
||||
return Get-ChildItem $toolcachePath -Name | Sort-Object { [Version] $_ }
|
||||
}
|
||||
|
||||
function Get-ToolcacheNodeVersions {
|
||||
$toolcachePath = Join-Path $env:AGENT_TOOLSDIRECTORY "Node"
|
||||
return Get-ChildItem $toolcachePath -Name | Sort-Object { [Version]$_ }
|
||||
return Get-ChildItem $toolcachePath -Name | Sort-Object { [Version] $_ }
|
||||
}
|
||||
|
||||
function Get-ToolcachePythonVersions {
|
||||
$toolcachePath = Join-Path $env:AGENT_TOOLSDIRECTORY "Python"
|
||||
return Get-ChildItem $toolcachePath -Name | Sort-Object { [Version]$_ }
|
||||
return Get-ChildItem $toolcachePath -Name | Sort-Object { [Version] $_ }
|
||||
}
|
||||
|
||||
function Get-ToolcacheRubyVersions {
|
||||
$toolcachePath = Join-Path $env:AGENT_TOOLSDIRECTORY "Ruby"
|
||||
return Get-ChildItem $toolcachePath -Name | Sort-Object { [Version]$_ }
|
||||
return Get-ChildItem $toolcachePath -Name | Sort-Object { [Version] $_ }
|
||||
}
|
||||
|
||||
function Get-ToolcachePyPyVersions {
|
||||
$toolcachePath = Join-Path $env:AGENT_TOOLSDIRECTORY "PyPy"
|
||||
Get-ChildItem -Path $toolcachePath -Name | Sort-Object { [Version] $_ } | ForEach-Object {
|
||||
$pypyRootPath = Join-Path $toolcachePath $_ "x86"
|
||||
[string]$pypyVersionOutput = & "$pypyRootPath\python.exe" -c "import sys;print(sys.version)"
|
||||
[string] $pypyVersionOutput = & "$pypyRootPath\python.exe" -c "import sys;print(sys.version)"
|
||||
$pypyVersionOutput -match "^([\d\.]+) \(.+\) \[PyPy ([\d\.]+\S*) .+]$" | Out-Null
|
||||
return "{0} [PyPy {1}]" -f $Matches[1], $Matches[2]
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@ function Initialize-RustEnvironment {
|
||||
}
|
||||
|
||||
function Get-OSName {
|
||||
return (Get-CimInstance -ClassName Win32_OperatingSystem).Caption | Take-Part -Part 1,2,3
|
||||
return (Get-CimInstance -ClassName Win32_OperatingSystem).Caption | Get-StringPart -Part 1,2,3
|
||||
}
|
||||
|
||||
function Get-OSVersion {
|
||||
@@ -26,75 +26,75 @@ function Get-BashVersion {
|
||||
}
|
||||
|
||||
function Get-RustVersion {
|
||||
rustc --version | Take-Part -Part 1
|
||||
rustc --version | Get-StringPart -Part 1
|
||||
}
|
||||
|
||||
function Get-RustupVersion {
|
||||
cmd /c "rustup --version 2>NUL" | Take-Part -Part 1
|
||||
cmd /c "rustup --version 2>NUL" | Get-StringPart -Part 1
|
||||
}
|
||||
|
||||
function Get-RustCargoVersion {
|
||||
cargo --version | Take-Part -Part 1
|
||||
cargo --version | Get-StringPart -Part 1
|
||||
}
|
||||
|
||||
function Get-RustdocVersion {
|
||||
rustdoc --version | Take-Part -Part 1
|
||||
rustdoc --version | Get-StringPart -Part 1
|
||||
}
|
||||
|
||||
function Get-RustfmtVersion {
|
||||
rustfmt --version | Take-Part -Part 1 | Take-Part -Part 0 -Delimiter ('-')
|
||||
rustfmt --version | Get-StringPart -Part 1 | Get-StringPart -Part 0 -Delimiter ('-')
|
||||
}
|
||||
|
||||
function Get-RustClippyVersion {
|
||||
cargo clippy --version | Take-Part -Part 1
|
||||
cargo clippy --version | Get-StringPart -Part 1
|
||||
}
|
||||
|
||||
function Get-BindgenVersion {
|
||||
bindgen --version | Take-Part -Part 1
|
||||
bindgen --version | Get-StringPart -Part 1
|
||||
}
|
||||
|
||||
function Get-CbindgenVersion {
|
||||
cbindgen --version | Take-Part -Part 1
|
||||
cbindgen --version | Get-StringPart -Part 1
|
||||
}
|
||||
|
||||
function Get-CargoAuditVersion {
|
||||
cargo-audit --version | Take-Part -Part 1
|
||||
cargo-audit --version | Get-StringPart -Part 1
|
||||
}
|
||||
|
||||
function Get-CargoOutdatedVersion {
|
||||
cargo outdated --version | Take-Part -Part 1
|
||||
cargo outdated --version | Get-StringPart -Part 1
|
||||
}
|
||||
|
||||
function Get-PythonVersion {
|
||||
python --version | Take-Part -Part 1
|
||||
python --version | Get-StringPart -Part 1
|
||||
}
|
||||
|
||||
function Get-PowershellCoreVersion {
|
||||
pwsh --version | Take-Part -Part 1
|
||||
pwsh --version | Get-StringPart -Part 1
|
||||
}
|
||||
|
||||
function Get-RubyVersion {
|
||||
ruby --version | Take-Part -Part 1
|
||||
ruby --version | Get-StringPart -Part 1
|
||||
}
|
||||
|
||||
function Get-GoVersion {
|
||||
go version | Take-Part -Part 2 | Take-Part -Part 1 -Delimiter ('o')
|
||||
go version | Get-StringPart -Part 2 | Get-StringPart -Part 1 -Delimiter ('o')
|
||||
}
|
||||
|
||||
function Get-KotlinVersion {
|
||||
cmd /c "kotlinc -version 2>&1" | Take-Part -Part 2
|
||||
cmd /c "kotlinc -version 2>&1" | Get-StringPart -Part 2
|
||||
}
|
||||
|
||||
function Get-PHPVersion {
|
||||
php --version | Out-String | Take-Part -Part 1
|
||||
php --version | Out-String | Get-StringPart -Part 1
|
||||
}
|
||||
|
||||
function Get-JuliaVersion {
|
||||
julia --version | Take-Part -Part 2
|
||||
julia --version | Get-StringPart -Part 2
|
||||
}
|
||||
|
||||
function Get-LLVMVersion {
|
||||
(clang --version) -match "clang" | Take-Part -Part 2
|
||||
(clang --version) -match "clang" | Get-StringPart -Part 2
|
||||
}
|
||||
|
||||
function Get-PerlVersion {
|
||||
@@ -104,7 +104,7 @@ function Get-PerlVersion {
|
||||
}
|
||||
|
||||
function Get-NodeVersion {
|
||||
node --version | Take-Part -Part 0 -Delimiter ('v')
|
||||
node --version | Get-StringPart -Part 0 -Delimiter ('v')
|
||||
}
|
||||
|
||||
function Get-ChocoVersion {
|
||||
@@ -135,7 +135,7 @@ function Get-HelmVersion {
|
||||
}
|
||||
|
||||
function Get-PipVersion {
|
||||
(pip --version) -match "pip" | Take-Part -Part 1,4,5
|
||||
(pip --version) -match "pip" | Get-StringPart -Part 1, 4, 5
|
||||
}
|
||||
|
||||
function Get-CondaVersion {
|
||||
@@ -144,19 +144,19 @@ function Get-CondaVersion {
|
||||
}
|
||||
|
||||
function Get-ComposerVersion {
|
||||
composer --version | Take-Part -Part 2
|
||||
composer --version | Get-StringPart -Part 2
|
||||
}
|
||||
|
||||
function Get-NugetVersion {
|
||||
(nuget help) -match "Nuget Version" | Take-Part -Part 2
|
||||
(nuget help) -match "Nuget Version" | Get-StringPart -Part 2
|
||||
}
|
||||
|
||||
function Get-AntVersion {
|
||||
ant -version | Take-Part -Part 3
|
||||
ant -version | Get-StringPart -Part 3
|
||||
}
|
||||
|
||||
function Get-MavenVersion {
|
||||
(mvn -version) -match "Apache Maven" | Take-Part -Part 2
|
||||
(mvn -version) -match "Apache Maven" | Get-StringPart -Part 2
|
||||
}
|
||||
|
||||
function Get-GradleVersion {
|
||||
@@ -166,16 +166,16 @@ function Get-GradleVersion {
|
||||
}
|
||||
|
||||
function Get-SbtVersion {
|
||||
(sbt -version) -match "sbt script" | Take-Part -Part 3
|
||||
(sbt -version) -match "sbt script" | Get-StringPart -Part 3
|
||||
}
|
||||
|
||||
function Get-DotnetSdks {
|
||||
$sdksRawList = dotnet --list-sdks
|
||||
$sdkVersions = $sdksRawList | Foreach-Object {$_.Split()[0]}
|
||||
$sdkVersions = $sdksRawList | Foreach-Object { $_.Split()[0] }
|
||||
$sdkPath = $sdksRawList[0].Split(' ', 2)[1] -replace '\[|]'
|
||||
[PSCustomObject]@{
|
||||
Versions = $sdkVersions
|
||||
Path = $sdkPath
|
||||
Path = $sdkPath
|
||||
}
|
||||
}
|
||||
|
||||
@@ -185,7 +185,7 @@ function Get-DotnetTools {
|
||||
|
||||
$toolsList = @()
|
||||
|
||||
foreach ($dotnetTool in $dotnetTools) {
|
||||
foreach ($dotnetTool in $dotnetTools) {
|
||||
$version = Invoke-Expression $dotnetTool.getversion
|
||||
$toolsList += [ToolVersionNode]::new($dotnetTool.name, $version)
|
||||
}
|
||||
@@ -194,21 +194,21 @@ function Get-DotnetTools {
|
||||
|
||||
function Get-DotnetRuntimes {
|
||||
$runtimesRawList = dotnet --list-runtimes
|
||||
$runtimesRawList | Group-Object {$_.Split()[0]} | ForEach-Object {
|
||||
$runtimesRawList | Group-Object { $_.Split()[0] } | ForEach-Object {
|
||||
$runtimeName = $_.Name
|
||||
$runtimeVersions = $_.Group | Foreach-Object {$_.split()[1]}
|
||||
$runtimeVersions = $_.Group | Foreach-Object { $_.split()[1] }
|
||||
$runtimePath = $_.Group[0].Split(' ', 3)[2] -replace '\[|]'
|
||||
[PSCustomObject]@{
|
||||
"Runtime" = $runtimeName
|
||||
"Runtime" = $runtimeName
|
||||
"Versions" = $runtimeVersions
|
||||
"Path" = $runtimePath
|
||||
"Path" = $runtimePath
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function Get-DotnetFrameworkVersions {
|
||||
$path = "${env:ProgramFiles(x86)}\Microsoft SDKs\Windows\*\*\NETFX * Tools"
|
||||
return Get-ChildItem -Path $path -Directory | ForEach-Object { $_.Name | Take-Part -Part 1 }
|
||||
return Get-ChildItem -Path $path -Directory | ForEach-Object { $_.Name | Get-StringPart -Part 1 }
|
||||
}
|
||||
|
||||
function Get-PowerShellAzureModules {
|
||||
@@ -276,20 +276,21 @@ function Get-CachedDockerImagesTableData {
|
||||
$parts = $_.Split("|")
|
||||
[PSCustomObject] @{
|
||||
"Repository:Tag" = $parts[0]
|
||||
"Digest" = $parts[1]
|
||||
"Created" = $parts[2].split(' ')[0]
|
||||
"Digest" = $parts[1]
|
||||
"Created" = $parts[2].split(' ')[0]
|
||||
}
|
||||
} | Sort-Object -Property "Repository:Tag"
|
||||
}
|
||||
|
||||
function Get-ShellTarget {
|
||||
return Get-ChildItem C:\shells -File | Select-Object Name, @{n="Target";e={
|
||||
if ($_.Name -eq "msys2bash.cmd") {
|
||||
"C:\msys64\usr\bin\bash.exe"
|
||||
} else {
|
||||
@($_.Target)[0]
|
||||
return Get-ChildItem C:\shells -File | Select-Object Name, @{n = "Target"; e = {
|
||||
if ($_.Name -eq "msys2bash.cmd") {
|
||||
"C:\msys64\usr\bin\bash.exe"
|
||||
} else {
|
||||
@($_.Target)[0]
|
||||
}
|
||||
}
|
||||
}} | Sort-Object Name
|
||||
} | Sort-Object Name
|
||||
}
|
||||
|
||||
function Get-PacmanVersion {
|
||||
@@ -302,7 +303,7 @@ function Get-PacmanVersion {
|
||||
}
|
||||
|
||||
function Get-YAMLLintVersion {
|
||||
yamllint --version | Take-Part -Part 1
|
||||
yamllint --version | Get-StringPart -Part 1
|
||||
}
|
||||
|
||||
function Get-BizTalkVersion {
|
||||
|
||||
@@ -17,7 +17,7 @@ function Get-PathWithLink {
|
||||
return "${inputPath}${link}"
|
||||
}
|
||||
|
||||
function Take-Part {
|
||||
function Get-StringPart {
|
||||
param (
|
||||
[Parameter(ValueFromPipeline)]
|
||||
[string] $toolOutput,
|
||||
@@ -27,4 +27,4 @@ function Take-Part {
|
||||
$parts = $toolOutput.Split($Delimiter, [System.StringSplitOptions]::RemoveEmptyEntries)
|
||||
$selectedParts = $parts[$Part]
|
||||
return [string]::Join($Delimiter, $selectedParts)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@ function Get-JavaVersions {
|
||||
$defaultJavaPath = $env:JAVA_HOME
|
||||
$javaVersions = Get-Item env:JAVA_HOME_*_X64
|
||||
$sortRules = @{
|
||||
Expression = { [Int32]$_.Name.Split("_")[2] }
|
||||
Expression = { [Int32] $_.Name.Split("_")[2] }
|
||||
Descending = $false
|
||||
}
|
||||
|
||||
@@ -19,4 +19,4 @@ function Get-JavaVersions {
|
||||
"Environment Variable" = $_.Name
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -66,12 +66,12 @@ function Get-DockerComposeVersionV2 {
|
||||
}
|
||||
|
||||
function Get-DockerWincredVersion {
|
||||
$dockerCredVersion = docker-credential-wincred version | Take-Part -Part 2 | Take-Part -Part 0 -Delimiter "v"
|
||||
$dockerCredVersion = docker-credential-wincred version | Get-StringPart -Part 2 | Get-StringPart -Part 0 -Delimiter "v"
|
||||
return $dockerCredVersion
|
||||
}
|
||||
|
||||
function Get-GitVersion {
|
||||
$gitVersion = git --version | Take-Part -Part -1
|
||||
$gitVersion = git --version | Get-StringPart -Part -1
|
||||
return $gitVersion
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user