Notifications for Node and Go versions not on image (#44)

This commit is contained in:
Maksim Shilov
2021-12-10 16:44:19 +03:00
committed by GitHub
parent de5faa4d9c
commit 33b79844a6
4 changed files with 59 additions and 33 deletions
+26 -1
View File
@@ -16,17 +16,42 @@ jobs:
tool: tool:
- name: 'Xamarin' - name: 'Xamarin'
image: 'https://avatars.githubusercontent.com/u/790012?s=200&v=4' image: 'https://avatars.githubusercontent.com/u/790012?s=200&v=4'
releases-url: 'null'
filter-parameter: 'null'
filter-arch: 'null'
- name: 'Python' - name: 'Python'
image: 'https://avatars.githubusercontent.com/u/1525981?s=200&v=4' image: 'https://avatars.githubusercontent.com/u/1525981?s=200&v=4'
releases-url: 'https://raw.githubusercontent.com/actions/python-versions/main/versions-manifest.json'
filter-parameter: 'version'
filter-arch: 'x64'
- name: 'PyPy' - name: 'PyPy'
image: 'https://avatars.githubusercontent.com/u/318667?s=200&v=4' image: 'https://avatars.githubusercontent.com/u/318667?s=200&v=4'
releases-url: 'https://downloads.python.org/pypy/versions.json'
filter-parameter: 'python_version'
filter-arch: 'x86'
- name: 'Node'
image: 'https://avatars.githubusercontent.com/u/9950313?s=200&v=4'
releases-url: 'https://raw.githubusercontent.com/actions/node-versions/main/versions-manifest.json'
filter-parameter: 'version'
filter-arch: 'x64'
- name: 'Go'
image: 'https://avatars.githubusercontent.com/u/4314092?s=200&v=4'
releases-url: 'https://raw.githubusercontent.com/actions/go-versions/main/versions-manifest.json'
filter-parameter: 'version'
filter-arch: 'x64'
name: 'Searching for new versions of ${{ matrix.tool.name }}' name: 'Searching for new versions of ${{ matrix.tool.name }}'
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v2
- id: get-new-tool-versions - id: get-new-tool-versions
name: Get new tool versions name: Get new tool versions
run: echo "::set-output name=versions-output::$(./get-new-tool-versions/verify-new-tool-version-added-to-image.ps1 -ToolName ${{ matrix.tool.name }})" run: |
$versionsOutput = ./get-new-tool-versions/verify-new-tool-version-added-to-image.ps1 `
-ToolName ${{ matrix.tool.name }} `
-ReleasesUrl ${{ matrix.tool.releases-url }} `
-FilterParameter ${{ matrix.tool.filter-parameter }} `
-FilterArch ${{ matrix.tool.filter-arch }}
echo "::set-output name=versions-output::$versionsOutput"
- name: Check versions - name: Check versions
if: steps.get-new-tool-versions.outputs.versions-output == '' if: steps.get-new-tool-versions.outputs.versions-output == ''
run: Write-Host "No new versions found" run: Write-Host "No new versions found"
@@ -0,0 +1,25 @@
function Search-ToolsVersionsNotOnImage {
param (
[string]$ToolName,
[string]$ReleasesUrl,
[string]$FilterParameter,
[string]$FilterArch
)
$stableReleases = (Invoke-RestMethod $ReleasesUrl) | Where-Object stable -eq $true
$stableReleaseVersions = $stableReleases | ForEach-Object {
if ($ToolName -eq "Node") {
$_.$FilterParameter.split(".")[0] + ".0"
} else {
$_.$FilterParameter.split(".")[0,1] -join"."
}
} | Select-Object -Unique
$toolsetUrl = "https://raw.githubusercontent.com/actions/virtual-environments/main/images/win/toolsets/toolset-2022.json"
$latestMinorVersion = (Invoke-RestMethod $toolsetUrl).toolcache |
Where-Object {$_.name -eq $ToolName -and $_.arch -eq $FilterArch} |
ForEach-Object {$_.versions.Replace("*","0")} |
Select-Object -Last 1
$versionsToAdd = $stableReleaseVersions | Where-Object {[version]$_ -gt [version]$latestMinorVersion}
return $versionsToAdd
}
@@ -1,21 +0,0 @@
function Search-PythonVersionsNotOnImage {
param (
[string]$ToolName,
[string]$ReleasesUrl,
[string]$FilterParameter,
[string]$FilterArch
)
$stableReleases = (Invoke-RestMethod $ReleasesUrl) |
Where-Object stable -eq $true |
ForEach-Object {$_.$FilterParameter.split(".")[0,1] -join"."} |
Select-Object -Unique
$toolsetUrl = "https://raw.githubusercontent.com/actions/virtual-environments/main/images/win/toolsets/toolset-2022.json"
$latestVersion = ((Invoke-RestMethod $toolsetUrl).toolcache |
Where-Object {$_.name -eq $ToolName -and $_.arch -eq $FilterArch}).versions |
Select-Object -Last 1
$latestMinorVesion = $latestVersion.TrimEnd(".*")
$versionsToAdd = $stableReleases | Where-Object {[version]$_ -gt [version]$latestMinorVesion}
return $versionsToAdd
}
@@ -3,25 +3,22 @@
Check and return list of new available tool versions that not added to toolsets yet Check and return list of new available tool versions that not added to toolsets yet
.PARAMETER ToolName .PARAMETER ToolName
Required parameter. The name of tool for which parser is available (Python, Xamarin, PyPy) Required parameter. The name of tool for which parser is available (Python, Xamarin, PyPy, Node, Go)
#> #>
param ( param (
[Parameter(Mandatory)] [Parameter(Mandatory)]
[ValidateSet("Python", "Xamarin", "PyPy")] [ValidateSet("Python", "Xamarin", "PyPy", "Node", "Go")]
[string]$ToolName [string] $ToolName,
[string] $ReleasesUrl,
[string] $FilterParameter,
[string] $FilterArch
) )
Get-ChildItem "$PSScriptRoot/parsers/verify-added-to-image/" | ForEach-Object {Import-Module $_.FullName} Get-ChildItem "$PSScriptRoot/parsers/verify-added-to-image/" | ForEach-Object {Import-Module $_.FullName}
if ($ToolName -eq "Python") { if ($ToolName -in "Python", "PyPy", "Node", "Go") {
$pythonVesionsManifestUrl = "https://raw.githubusercontent.com/actions/python-versions/main/versions-manifest.json" $versionsToAdd = Search-ToolsVersionsNotOnImage -ToolName $ToolName -ReleasesUrl $ReleasesUrl -FilterParameter $FilterParameter -FilterArch $FilterArch
$versionsToAdd = Search-PythonVersionsNotOnImage -ToolName $ToolName -ReleasesUrl $pythonVesionsManifestUrl -FilterParameter "version" -FilterArch "x64"
}
if ($ToolName -eq "PyPy") {
$pypyReleases = "https://downloads.python.org/pypy/versions.json"
$versionsToAdd = Search-PythonVersionsNotOnImage -ToolName $ToolName -ReleasesUrl $pypyReleases -FilterParameter "python_version" -FilterArch "x86"
} }
if ($ToolName -eq "Xamarin") { if ($ToolName -eq "Xamarin") {