New parser for xamarin and python. Reworked workflow with composite actions (#41)

This commit is contained in:
Maksim Shilov
2021-10-27 10:31:19 +03:00
committed by GitHub
parent 6f1aa3ce73
commit a753279554
5 changed files with 178 additions and 74 deletions

View File

@@ -14,6 +14,8 @@ Optional parameter. The pipeline URL
Optional parameter. The image URL
.PARAMETER Text
Optional parameter. The message to post
.PARAMETER AddToToolsetFlag
Optional parameter. Flag to alternate message text for adding new version of a tool to toolset notification
#>
param(
@@ -28,7 +30,8 @@ param(
[System.String]$ToolVersion,
[System.String]$PipelineUrl,
[System.String]$ImageUrl = 'https://github.githubassets.com/images/modules/logos_page/GitHub-Mark.png',
[System.String]$Text
[System.String]$Text,
[Switch]$AddToToolsetFlag
)
# Import helpers module
@@ -36,15 +39,16 @@ Import-Module $PSScriptRoot/helpers.psm1 -DisableNameChecking
# Create JSON body
if ([string]::IsNullOrWhiteSpace($Text)) {
if ($toolName -eq "Xamarin") {
if ($AddToToolsetFlag) {
$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"
}
}
if (-not ([string]::IsNullOrWhiteSpace($PipelineUrl))) {
$Text += "\nLink to the pipeline: $pipelineUrl"
}
$jsonBodyMessage = @"
{
"blocks": [

View File

@@ -0,0 +1,48 @@
<#
.SYNOPSIS
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)
#>
param (
[Parameter(Mandatory)]
[ValidateSet("Python", "Xamarin")]
[string]$ToolName
)
if ($ToolName -eq "Python") {
$pythonVesionsManifestUrl = "https://raw.githubusercontent.com/actions/python-versions/main/versions-manifest.json"
$builtStableMinorVersions = (Invoke-RestMethod $pythonVesionsManifestUrl) |
Where-Object stable -eq $true |
ForEach-Object {$_.version.split(".")[0,1] -join"."} |
Select-Object -Unique
$toolsetUrl = "https://raw.githubusercontent.com/actions/virtual-environments/main/images/win/toolsets/toolset-2019.json"
$latestExistingMinorVesion = ((Invoke-RestMethod $toolsetUrl).toolcache |
Where-Object {$_.name -eq "Python" -and $_.arch -eq "x64"}).versions |
ForEach-Object {$_.split(".")[0,1] -join"."} |
Select-Object -Last 1
$versionsToAdd = $builtStableMinorVersions | Where-Object {[version]$_ -gt [version]$latestExistingMinorVesion}
}
if ($ToolName -eq "Xamarin") {
$xamarinReleases = (Invoke-RestMethod "http://aka.ms/manifest/stable").items
$xamarinProducts = @('Mono Framework', 'Xamarin.Android', 'Xamarin.iOS', 'Xamarin.Mac')
$filteredReleases = $xamarinReleases | Where-Object {$_.name -in $xamarinProducts} | Sort-Object name | Select-Object name, version
$toolsetUrl = "https://raw.githubusercontent.com/actions/virtual-environments/main/images/macos/toolsets/toolset-11.json"
$uploadedReleases = (Invoke-RestMethod $toolsetUrl).xamarin
$releasesOnImage = @{
'Mono Framework' = $uploadedReleases.'mono-versions'
'Xamarin.Android' = $uploadedReleases.'android-versions'
'Xamarin.iOS' = $uploadedReleases.'ios-versions'
'Xamarin.Mac' = $uploadedReleases.'mac-versions'
}
$versionsToAdd = $filteredReleases | Where-Object {$releasesOnImage[$_.name] -notcontains $_.version } | ForEach-Object {[string]::Empty} {
'{0,-15} : {1}' -f $_.name, $_.version
}
$joinChars = "\n\t"
}
$versionsToAdd = $versionsToAdd -join $joinChars
return $versionsToAdd