From 7ec75e0761376c2b97aa20c3ca6c5504e9d852b5 Mon Sep 17 00:00:00 2001 From: Aleksandr Chebotov Date: Fri, 19 Mar 2021 15:23:57 +0300 Subject: [PATCH 1/5] add xamarin tool version --- azure-pipelines/get-tool-versions-xamarin.yml | 37 +++++++++++++++++++ azure-pipelines/templates/check-versions.yml | 4 +- .../get-new-tool-versions.ps1 | 14 +++++-- .../parsers/parsers-factory.psm1 | 2 + .../parsers/xamarin-parser.psm1 | 30 +++++++++++++++ 5 files changed, 82 insertions(+), 5 deletions(-) create mode 100644 azure-pipelines/get-tool-versions-xamarin.yml create mode 100644 get-new-tool-versions/parsers/xamarin-parser.psm1 diff --git a/azure-pipelines/get-tool-versions-xamarin.yml b/azure-pipelines/get-tool-versions-xamarin.yml new file mode 100644 index 0000000..866f810 --- /dev/null +++ b/azure-pipelines/get-tool-versions-xamarin.yml @@ -0,0 +1,37 @@ +name: $(date:yyyyMMdd)$(rev:.r) +trigger: none +pr: none +schedules: +- cron: "0 8 * * Thu" + displayName: Daily build + branches: + include: + - main + always: true + +variables: + PoolName: 'Azure Pipelines' + VmImage: 'ubuntu-18.04' + +stages: +- stage: Find_New_Versions + dependsOn: [] + jobs: + - job: Find_New_Versions + pool: + name: $(PoolName) + vmImage: $(VmImage) + steps: + - template: /azure-pipelines/templates/get-tool-versions-steps.yml + +- stage: Check_New_Versions + dependsOn: Find_New_Versions + jobs: + - job: Check_New_Versions + pool: + name: $(PoolName) + vmImage: $(VmImage) + variables: + ToolVersions: $[ stageDependencies.Find_New_Versions.Find_New_Versions.outputs['Get_versions.TOOL_VERSIONS'] ] + steps: + - template: /azure-pipelines/templates/check-versions.yml diff --git a/azure-pipelines/templates/check-versions.yml b/azure-pipelines/templates/check-versions.yml index c7ad39f..b6c027a 100644 --- a/azure-pipelines/templates/check-versions.yml +++ b/azure-pipelines/templates/check-versions.yml @@ -21,7 +21,7 @@ steps: TargetType: inline script: | $ToolName = "$(TOOL_NAME)" - if ($ToolName -eq "Python") { + if ($ToolName -in @("Python", "Xamarin") { $PipelineUrl = " " } else { $PipelineUrl = "$(System.TeamFoundationCollectionUri)$(System.TeamProject)/_build/results?buildId=$(Build.BuildId)" @@ -36,7 +36,7 @@ steps: $newBuildName = "[FOUND] $(Build.BuildNumber)" Write-Host "##vso[build.updatebuildnumber]$newBuildName" -- task: PowerShell@2 +- task: PowerShell@2 displayName: 'Send Slack notification' inputs: targetType: filePath diff --git a/get-new-tool-versions/get-new-tool-versions.ps1 b/get-new-tool-versions/get-new-tool-versions.ps1 index e2f0474..bab022b 100644 --- a/get-new-tool-versions/get-new-tool-versions.ps1 +++ b/get-new-tool-versions/get-new-tool-versions.ps1 @@ -3,7 +3,7 @@ Check and return list of new available tool versions .PARAMETER ToolName -Required parameter. The name of tool for which parser is available (Node, Go, Python) +Required parameter. The name of tool for which parser is available (Node, Go, Python, Xamarin) #> param ( @@ -16,10 +16,18 @@ $ToolVersionParser = Get-ToolVersionsParser -ToolName $ToolName $VersionsFromDist = $ToolVersionParser.GetAvailableVersions() $VersionsFromManifest = $ToolVersionParser.GetUploadedVersions() -$VersionsToBuild = $VersionsFromDist | Where-Object { $VersionsFromManifest -notcontains $_ } +$joinChars = ", " +if ($ToolName -eq "Xamarin") { + $VersionsToBuild = $VersionsFromDist | Where-Object { $VersionsFromManifest[$_.name] -notcontains $_.version } | ForEach-Object { + '{0,-15} : {1}' -f $_.name, $_.version + } + $joinChars = "\n" +} else { + $VersionsToBuild = $VersionsFromDist | Where-Object { $VersionsFromManifest -notcontains $_ } +} if ($VersionsToBuild) { - $availableVersions = $VersionsToBuild -join ", " + $availableVersions = $VersionsToBuild -join $joinChars Write-Host "The following versions are available to build:`n${availableVersions}" Write-Host "##vso[task.setvariable variable=TOOL_VERSIONS;isOutput=true]${availableVersions}" } else { diff --git a/get-new-tool-versions/parsers/parsers-factory.psm1 b/get-new-tool-versions/parsers/parsers-factory.psm1 index eb9b69c..199136c 100644 --- a/get-new-tool-versions/parsers/parsers-factory.psm1 +++ b/get-new-tool-versions/parsers/parsers-factory.psm1 @@ -1,6 +1,7 @@ using module "./node-parser.psm1" using module "./go-parser.psm1" using module "./python-parser.psm1" +using module "./xamarin-parser.psm1" function Get-ToolVersionsParser { param( @@ -12,6 +13,7 @@ function Get-ToolVersionsParser { "Node" { return [NodeVersionsParser]::New() } "Go" { return [GoVersionsParser]::New() } "Python" { return [PythonVersionsParser]::New() } + "Xamarin" { return [XamarinversionsParser]::New() } Default { throw "Unknown tool name" } diff --git a/get-new-tool-versions/parsers/xamarin-parser.psm1 b/get-new-tool-versions/parsers/xamarin-parser.psm1 new file mode 100644 index 0000000..7d69416 --- /dev/null +++ b/get-new-tool-versions/parsers/xamarin-parser.psm1 @@ -0,0 +1,30 @@ +using module "./base-parser.psm1" + +class XamarinVersionsParser: BaseVersionsParser { + [PSCustomObject] GetAvailableVersions() { + $allVersions = $this.ParseAllAvailableVersions() + return $allVersions + } + + [hashtable] GetUploadedVersions() { + $url = $this.BuildGitHubFileUrl("actions", "virtual-environments", "main", "images/macos/toolsets/toolset-11.0.json") + $releases = Invoke-RestMethod $url -MaximumRetryCount $this.ApiRetryCount -RetryIntervalSec $this.ApiRetryIntervalSeconds + $xamarin = $releases.xamarin + $xamarinReleases = @{ + 'Mono Framework' = $xamarin.'mono-versions' + 'Xamarin.Android' = $xamarin.'android-versions' + 'Xamarin.iOS' = $xamarin.'ios-versions' + 'Xamarin.Mac' = $xamarin.'mac-versions' + } + return $xamarinReleases + } + + hidden [PSCustomObject] ParseAllAvailableVersions() { + $url = "http://aka.ms/manifest/stable" + $filteredProducts = @('Mono Framework', 'Xamarin.Android', 'Xamarin.iOS', 'Xamarin.Mac') + $releases = Invoke-RestMethod $url -MaximumRetryCount $this.ApiRetryCount -RetryIntervalSec $this.ApiRetryIntervalSeconds + $items = $releases.items + $products = $items | Where-Object {$_.name -in $filteredProducts} | Sort-Object name | Select-Object name, version + return $products + } +} \ No newline at end of file From 81507e485bbfb26fc947bea20be17627676e7c0a Mon Sep 17 00:00:00 2001 From: Aleksandr Chebotov Date: Fri, 19 Mar 2021 15:45:09 +0300 Subject: [PATCH 2/5] fix format --- get-new-tool-versions/get-new-tool-versions.ps1 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/get-new-tool-versions/get-new-tool-versions.ps1 b/get-new-tool-versions/get-new-tool-versions.ps1 index bab022b..75e0353 100644 --- a/get-new-tool-versions/get-new-tool-versions.ps1 +++ b/get-new-tool-versions/get-new-tool-versions.ps1 @@ -18,10 +18,10 @@ $VersionsFromManifest = $ToolVersionParser.GetUploadedVersions() $joinChars = ", " if ($ToolName -eq "Xamarin") { - $VersionsToBuild = $VersionsFromDist | Where-Object { $VersionsFromManifest[$_.name] -notcontains $_.version } | ForEach-Object { + $VersionsToBuild = $VersionsFromDist | Where-Object { $VersionsFromManifest[$_.name] -notcontains $_.version } | ForEach-Object {[string]::Empty} { '{0,-15} : {1}' -f $_.name, $_.version } - $joinChars = "\n" + $joinChars = "\n\t" } else { $VersionsToBuild = $VersionsFromDist | Where-Object { $VersionsFromManifest -notcontains $_ } } From 725c68b777db34cb2d81aa0468ac5be38fe4567a Mon Sep 17 00:00:00 2001 From: Aleksandr Chebotov Date: Mon, 22 Mar 2021 13:44:19 +0300 Subject: [PATCH 3/5] fix message --- get-new-tool-versions/send-slack-notification.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/get-new-tool-versions/send-slack-notification.ps1 b/get-new-tool-versions/send-slack-notification.ps1 index 050af3e..5b5aebb 100644 --- a/get-new-tool-versions/send-slack-notification.ps1 +++ b/get-new-tool-versions/send-slack-notification.ps1 @@ -35,7 +35,7 @@ param( Import-Module $PSScriptRoot/helpers.psm1 -DisableNameChecking # Create JSON body -$text = "The following versions of '$toolName' are available to upload: $toolVersion" +$text = "The following versions of '$toolName' are available, consider adding them to toolset: $toolVersion" if (-not ([string]::IsNullOrWhiteSpace($PipelineUrl))) { $text += "\nLink to the pipeline: $pipelineUrl" } From 77b53792b3ba629483a476d78753abd59102b985 Mon Sep 17 00:00:00 2001 From: Aleksandr Chebotov Date: Mon, 22 Mar 2021 21:35:24 +0300 Subject: [PATCH 4/5] update message for Xamarin --- get-new-tool-versions/send-slack-notification.ps1 | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/get-new-tool-versions/send-slack-notification.ps1 b/get-new-tool-versions/send-slack-notification.ps1 index 5b5aebb..3f3518a 100644 --- a/get-new-tool-versions/send-slack-notification.ps1 +++ b/get-new-tool-versions/send-slack-notification.ps1 @@ -35,7 +35,11 @@ param( Import-Module $PSScriptRoot/helpers.psm1 -DisableNameChecking # Create JSON body -$text = "The following versions of '$toolName' are available, consider adding them to toolset: $toolVersion" +if ($toolName -eq "Xamarin") { + $text = "The following versions of '$toolName' are available, consider adding them to toolset: $toolVersion" +} else { + $text = "The following versions of '$toolName' are available to upload: $toolVersion" +} if (-not ([string]::IsNullOrWhiteSpace($PipelineUrl))) { $text += "\nLink to the pipeline: $pipelineUrl" } From 504e746b969d9a91037f5bf4f2750c37d987aa89 Mon Sep 17 00:00:00 2001 From: Aleksandr Chebotov Date: Wed, 5 May 2021 16:47:49 +0300 Subject: [PATCH 5/5] add missing bracket --- azure-pipelines/templates/check-versions.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/azure-pipelines/templates/check-versions.yml b/azure-pipelines/templates/check-versions.yml index b6c027a..9af96ef 100644 --- a/azure-pipelines/templates/check-versions.yml +++ b/azure-pipelines/templates/check-versions.yml @@ -21,7 +21,7 @@ steps: TargetType: inline script: | $ToolName = "$(TOOL_NAME)" - if ($ToolName -in @("Python", "Xamarin") { + if ($ToolName -in @("Python", "Xamarin")) { $PipelineUrl = " " } else { $PipelineUrl = "$(System.TeamFoundationCollectionUri)$(System.TeamProject)/_build/results?buildId=$(Build.BuildId)"