diff --git a/.github/workflows/get-tools-new-versions.yml b/.github/workflows/get-tools-new-versions.yml index ad06994..aeaaf74 100644 --- a/.github/workflows/get-tools-new-versions.yml +++ b/.github/workflows/get-tools-new-versions.yml @@ -16,17 +16,42 @@ jobs: tool: - name: 'Xamarin' image: 'https://avatars.githubusercontent.com/u/790012?s=200&v=4' + releases-url: 'null' + filter-parameter: 'null' + filter-arch: 'null' - name: 'Python' 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' 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 }}' runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 - id: 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 if: steps.get-new-tool-versions.outputs.versions-output == '' run: Write-Host "No new versions found" diff --git a/get-new-tool-versions/parsers/verify-added-to-image/verify-common-tool-parser.psm1 b/get-new-tool-versions/parsers/verify-added-to-image/verify-common-tool-parser.psm1 new file mode 100644 index 0000000..3723390 --- /dev/null +++ b/get-new-tool-versions/parsers/verify-added-to-image/verify-common-tool-parser.psm1 @@ -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 +} \ No newline at end of file diff --git a/get-new-tool-versions/parsers/verify-added-to-image/verify-python-parser.psm1 b/get-new-tool-versions/parsers/verify-added-to-image/verify-python-parser.psm1 deleted file mode 100644 index d8c6a55..0000000 --- a/get-new-tool-versions/parsers/verify-added-to-image/verify-python-parser.psm1 +++ /dev/null @@ -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 -} \ No newline at end of file diff --git a/get-new-tool-versions/verify-new-tool-version-added-to-image.ps1 b/get-new-tool-versions/verify-new-tool-version-added-to-image.ps1 index c4b088c..664729d 100644 --- a/get-new-tool-versions/verify-new-tool-version-added-to-image.ps1 +++ b/get-new-tool-versions/verify-new-tool-version-added-to-image.ps1 @@ -3,25 +3,22 @@ Check and return list of new available tool versions that not added to toolsets yet .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 ( [Parameter(Mandatory)] - [ValidateSet("Python", "Xamarin", "PyPy")] - [string]$ToolName + [ValidateSet("Python", "Xamarin", "PyPy", "Node", "Go")] + [string] $ToolName, + [string] $ReleasesUrl, + [string] $FilterParameter, + [string] $FilterArch ) Get-ChildItem "$PSScriptRoot/parsers/verify-added-to-image/" | ForEach-Object {Import-Module $_.FullName} -if ($ToolName -eq "Python") { - $pythonVesionsManifestUrl = "https://raw.githubusercontent.com/actions/python-versions/main/versions-manifest.json" - $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 -in "Python", "PyPy", "Node", "Go") { + $versionsToAdd = Search-ToolsVersionsNotOnImage -ToolName $ToolName -ReleasesUrl $ReleasesUrl -FilterParameter $FilterParameter -FilterArch $FilterArch } if ($ToolName -eq "Xamarin") {