mirror of
https://github.com/actions/versions-package-tools.git
synced 2025-12-10 19:50:24 +00:00
Compare commits
42 Commits
v-malob/fi
...
v-nibyko/g
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
742c5dae81 | ||
|
|
f3f0d2026d | ||
|
|
5e6f2c681c | ||
|
|
bb9fd35708 | ||
|
|
9f535cd83f | ||
|
|
750ff93e50 | ||
|
|
a29d98d3f2 | ||
|
|
538be710eb | ||
|
|
8f1a38e755 | ||
|
|
9fc854ce04 | ||
|
|
03ae7d095d | ||
|
|
97e0e3a660 | ||
|
|
b01e7843b6 | ||
|
|
856cb1ed00 | ||
|
|
6b744d4218 | ||
|
|
4b286369c5 | ||
|
|
65cd85d7fe | ||
|
|
7654b2e70d | ||
|
|
7847e40341 | ||
|
|
d853f172e3 | ||
|
|
46a901fa87 | ||
|
|
f19d5f4b3c | ||
|
|
00039881ba | ||
|
|
878c283d3b | ||
|
|
41a1acf1a4 | ||
|
|
2bd3b2a3c2 | ||
|
|
e81db48281 | ||
|
|
ab218c2436 | ||
|
|
504e746b96 | ||
|
|
4d97edc41a | ||
|
|
80bbe2ac05 | ||
|
|
77b53792b3 | ||
|
|
725c68b777 | ||
|
|
81507e485b | ||
|
|
7ec75e0761 | ||
|
|
590ebcd1ab | ||
|
|
cc2ef5ff7d | ||
|
|
e37209e8d6 | ||
|
|
3d7121daba | ||
|
|
f5bdb61b33 | ||
|
|
96a98e9fb3 | ||
|
|
5f0e0eebc8 |
1
.github/CODEOWNERS
vendored
Normal file
1
.github/CODEOWNERS
vendored
Normal file
@@ -0,0 +1 @@
|
||||
* @actions/virtual-environments-owners
|
||||
37
azure-pipelines/get-tool-versions-xamarin.yml
Normal file
37
azure-pipelines/get-tool-versions-xamarin.yml
Normal file
@@ -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
|
||||
@@ -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
|
||||
|
||||
@@ -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,11 +16,20 @@ $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 {[string]::Empty} {
|
||||
'{0,-15} : {1}' -f $_.name, $_.version
|
||||
}
|
||||
$joinChars = "\n\t"
|
||||
} 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 "::set-output name=TOOL_VERSIONS::${availableVersions}"
|
||||
Write-Host "##vso[task.setvariable variable=TOOL_VERSIONS;isOutput=true]${availableVersions}"
|
||||
} else {
|
||||
Write-Host "There aren't versions to build"
|
||||
|
||||
@@ -2,7 +2,7 @@ using module "./base-parser.psm1"
|
||||
|
||||
class GoVersionsParser: BaseVersionsParser {
|
||||
[SemVer[]] GetUploadedVersions() {
|
||||
$url = $this.BuildGitHubFileUrl("actions", "go-versions", "main", "versions-manifest.json")
|
||||
$url = $this.BuildGitHubFileUrl("nikita-bykov", "go-versions", "move-get-go-version", "versions-manifest.json")
|
||||
$releases = Invoke-RestMethod $url -MaximumRetryCount $this.ApiRetryCount -RetryIntervalSec $this.ApiRetryIntervalSeconds
|
||||
return $releases.version
|
||||
}
|
||||
@@ -15,10 +15,15 @@ class GoVersionsParser: BaseVersionsParser {
|
||||
|
||||
hidden [SemVer] FormatVersion([string]$VersionSpec) {
|
||||
$cleanVersion = $VersionSpec -replace "^go", ""
|
||||
return [SemVer]$cleanVersion
|
||||
$semanticVersion = $cleanVersion -replace '(\d+\.\d+\.?\d*?)((?:alpha|beta|rc))(\d*)', '$1-$2.$3'
|
||||
return [SemVer]$semanticVersion
|
||||
}
|
||||
|
||||
hidden [bool] ShouldIncludeVersion([SemVer]$Version) {
|
||||
if ($Version.PreReleaseLabel) {
|
||||
return $false
|
||||
}
|
||||
|
||||
# For Go, we include all versions greater than 1.12
|
||||
return $Version -gt [SemVer]"1.12.0"
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@ using module "./base-parser.psm1"
|
||||
|
||||
class NodeVersionsParser: BaseVersionsParser {
|
||||
[SemVer[]] GetUploadedVersions() {
|
||||
$url = $this.BuildGitHubFileUrl("actions", "node-versions", "main", "versions-manifest.json")
|
||||
$url = $this.BuildGitHubFileUrl("nikita-bykov", "node-versions", "move-get-node-versions-test", "versions-manifest.json")
|
||||
$releases = Invoke-RestMethod $url -MaximumRetryCount $this.ApiRetryCount -RetryIntervalSec $this.ApiRetryIntervalSeconds
|
||||
return $releases.version
|
||||
}
|
||||
|
||||
@@ -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"
|
||||
}
|
||||
|
||||
30
get-new-tool-versions/parsers/xamarin-parser.psm1
Normal file
30
get-new-tool-versions/parsers/xamarin-parser.psm1
Normal file
@@ -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.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
|
||||
}
|
||||
}
|
||||
60
get-new-tool-versions/send-slack-notification-failure.ps1
Normal file
60
get-new-tool-versions/send-slack-notification-failure.ps1
Normal file
@@ -0,0 +1,60 @@
|
||||
<#
|
||||
.SYNOPSIS
|
||||
Sending messages using Incoming Webhooks
|
||||
|
||||
.PARAMETER Url
|
||||
Required parameter. Incoming Webhook URL to post a message
|
||||
.PARAMETER ToolName
|
||||
Required parameter. The name of tool
|
||||
.PARAMETER ToolVersion
|
||||
Required parameter. Specifies the version of tool
|
||||
.PARAMETER PipelineUrl
|
||||
Required parameter. The pipeline URL
|
||||
.PARAMETER ImageUrl
|
||||
Optional parameter. The image URL
|
||||
#>
|
||||
|
||||
param(
|
||||
[Parameter(Mandatory)]
|
||||
[ValidateNotNullOrEmpty()]
|
||||
[System.Uri]$Url,
|
||||
|
||||
[Parameter(Mandatory)]
|
||||
[ValidateNotNullOrEmpty()]
|
||||
[System.String]$ToolName,
|
||||
|
||||
[Parameter(Mandatory)]
|
||||
[ValidateNotNullOrEmpty()]
|
||||
[System.String]$ToolVersion,
|
||||
|
||||
[System.String]$PipelineUrl,
|
||||
[System.String]$ImageUrl = 'https://github.githubassets.com/images/modules/logos_page/GitHub-Mark.png'
|
||||
)
|
||||
|
||||
# Import helpers module
|
||||
Import-Module $PSScriptRoot/helpers.psm1 -DisableNameChecking
|
||||
|
||||
# Create JSON body
|
||||
$text = "Some jobs were not successful for the following detection pipelines of '$ToolName'\nLink to the pipeline: '$pipelineUrl'"
|
||||
|
||||
$jsonBodyMessage = @"
|
||||
{
|
||||
"blocks": [
|
||||
{
|
||||
"type": "section",
|
||||
"text": {
|
||||
"type": "mrkdwn",
|
||||
"text": "$text"
|
||||
},
|
||||
"accessory": {
|
||||
"type": "image",
|
||||
"image_url": "$imageUrl",
|
||||
"alt_text": "$toolName"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
"@
|
||||
|
||||
# Send Slack message
|
||||
$null = Send-SlackPostMessageIncomingWebHook -Uri $url -Body $jsonBodyMessage
|
||||
@@ -23,21 +23,25 @@ param(
|
||||
[ValidateNotNullOrEmpty()]
|
||||
[System.String]$ToolName,
|
||||
|
||||
[Parameter(Mandatory)]
|
||||
[ValidateNotNullOrEmpty()]
|
||||
[System.String]$ToolVersion,
|
||||
|
||||
[System.String]$PipelineUrl,
|
||||
[System.String]$ImageUrl = 'https://github.githubassets.com/images/modules/logos_page/GitHub-Mark.png'
|
||||
[System.String]$ImageUrl = 'https://github.githubassets.com/images/modules/logos_page/GitHub-Mark.png',
|
||||
[System.String]$Text
|
||||
)
|
||||
|
||||
# Import helpers module
|
||||
Import-Module $PSScriptRoot/helpers.psm1 -DisableNameChecking
|
||||
|
||||
# Create JSON body
|
||||
$text = "The following versions of '$toolName' are available to upload: $toolVersion"
|
||||
if (-not ([string]::IsNullOrWhiteSpace($PipelineUrl))) {
|
||||
$text += "\nLink to the pipeline: $pipelineUrl"
|
||||
if ([string]::IsNullOrWhiteSpace($Text)) {
|
||||
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"
|
||||
}
|
||||
}
|
||||
$jsonBodyMessage = @"
|
||||
{
|
||||
@@ -46,7 +50,7 @@ $jsonBodyMessage = @"
|
||||
"type": "section",
|
||||
"text": {
|
||||
"type": "mrkdwn",
|
||||
"text": "$text"
|
||||
"text": "$Text"
|
||||
},
|
||||
"accessory": {
|
||||
"type": "image",
|
||||
|
||||
@@ -124,6 +124,11 @@ class GitHubApi
|
||||
}
|
||||
}
|
||||
|
||||
[void] CancelWorkflow([string]$WorkflowId) {
|
||||
$url = "actions/runs/$WorkflowId/cancel"
|
||||
$this.InvokeRestMethod($url, 'POST', $null, $null)
|
||||
}
|
||||
|
||||
[object] hidden InvokeRestMethod(
|
||||
[string] $Url,
|
||||
[string] $Method,
|
||||
|
||||
@@ -126,7 +126,7 @@ Describe "Build-VersionsManifest" {
|
||||
[PSCustomObject]@{ version = "3.8.3"; stable = $true; release_url = "fake_html_url"; files = $expectedManifestFiles }
|
||||
)
|
||||
[array]$actualManifest = Build-VersionsManifest -Releases $releases -Configuration $configuration
|
||||
Assert-Equivalent -Actual $actualManifest -Expected $expectedManifest
|
||||
Assert-Equivalent -Actual $actualManifest -Expected $expectedManifest
|
||||
}
|
||||
|
||||
It "take latest published release for each version" {
|
||||
@@ -161,4 +161,54 @@ Describe "Build-VersionsManifest" {
|
||||
[array]$actualManifest = Build-VersionsManifest -Releases $releases -Configuration $configuration
|
||||
Assert-Equivalent -Actual $actualManifest -Expected $expectedManifest
|
||||
}
|
||||
|
||||
It "set correct lts value for versions" {
|
||||
$releases = @(
|
||||
@{ name = "14.2.1"; draft = false; prerelease = $false; html_url = "fake_html_url"; published_at = "2020-05-14T09:54:06Z"; assets = $assets },
|
||||
@{ name = "12.0.1"; draft = $false; prerelease = false; html_url = "fake_html_url"; published_at = "2020-05-06T11:45:36Z"; assets = $assets },
|
||||
@{ name = "16.2.2"; draft = $false; prerelease = $false; html_url = "fake_html_url"; published_at = "2020-05-06T11:43:38Z"; assets = $assets }
|
||||
)
|
||||
$configuration = @{
|
||||
regex = "python-\d+\.\d+\.\d+-(\w+)-([\w\.]+)?-?(x\d+)";
|
||||
groups = [PSCustomObject]@{ platform = 1; platform_version = 2; arch = "x64"; }
|
||||
lts_rule_expression = "@(@{ Name = '14'; Value = 'Fermium' }, @{ Name = '12'; Value = 'Erbium' })"
|
||||
}
|
||||
$expectedManifest = @(
|
||||
[PSCustomObject]@{ version = "16.2.2"; stable = $true; release_url = "fake_html_url"; files = $expectedManifestFiles },
|
||||
[PSCustomObject]@{ version = "14.2.1"; stable = $true; lts = "Fermium"; release_url = "fake_html_url"; files = $expectedManifestFiles },
|
||||
[PSCustomObject]@{ version = "12.0.1"; stable = $true; lts = "Erbium"; release_url = "fake_html_url"; files = $expectedManifestFiles }
|
||||
)
|
||||
[array]$actualManifest = Build-VersionsManifest -Releases $releases -Configuration $configuration
|
||||
Assert-Equivalent -Actual $actualManifest -Expected $expectedManifest
|
||||
}
|
||||
}
|
||||
|
||||
Describe "Get-VersionLtsStatus" {
|
||||
$ltsRules = @(
|
||||
@{ Name = "14"; Value = "Fermium" },
|
||||
@{ Name = "12"; Value = "Erbium" },
|
||||
@{ Name = "10"; Value = $true },
|
||||
@{ Name = "8.3"; Value = "LTS 8.3" }
|
||||
)
|
||||
|
||||
It "lts label is matched" {
|
||||
Get-VersionLtsStatus -Version "14.2.2" -LtsRules $ltsRules | Should -Be "Fermium"
|
||||
Get-VersionLtsStatus -Version "12.3.1" -LtsRules $ltsRules | Should -Be "Erbium"
|
||||
Get-VersionLtsStatus -Version "10.8.1" -LtsRules $ltsRules | Should -Be $true
|
||||
Get-VersionLtsStatus -Version "8.3.2" -LtsRules $ltsRules | Should -Be "LTS 8.3"
|
||||
Get-VersionLtsStatus -Version "14" -LtsRules $ltsRules | Should -Be "Fermium"
|
||||
}
|
||||
|
||||
It "lts label is not matched" {
|
||||
Get-VersionLtsStatus -Version "9.1" -LtsRules $ltsRules | Should -Be $null
|
||||
Get-VersionLtsStatus -Version "13.8" -LtsRules $ltsRules | Should -Be $null
|
||||
Get-VersionLtsStatus -Version "5" -LtsRules $ltsRules | Should -Be $null
|
||||
Get-VersionLtsStatus -Version "8.4" -LtsRules $ltsRules | Should -Be $null
|
||||
Get-VersionLtsStatus -Version "142.5.1" -LtsRules $ltsRules | Should -Be $null
|
||||
}
|
||||
|
||||
It "no rules" {
|
||||
Get-VersionLtsStatus -Version "14.2.2" | Should -Be $null
|
||||
Get-VersionLtsStatus -Version "12.3.1" -LtsRules $null | Should -Be $null
|
||||
}
|
||||
}
|
||||
@@ -50,6 +50,7 @@ function Build-VersionsManifest {
|
||||
)
|
||||
|
||||
$Releases = $Releases | Sort-Object -Property "published_at" -Descending
|
||||
$ltsRules = Get-LtsRules -Configuration $Configuration
|
||||
|
||||
$versionsHash = @{}
|
||||
foreach ($release in $Releases) {
|
||||
@@ -64,17 +65,49 @@ function Build-VersionsManifest {
|
||||
continue
|
||||
}
|
||||
|
||||
$ltsStatus = Get-VersionLtsStatus -Version $versionKey -LtsRules $ltsRules
|
||||
$stable = $version.PreReleaseLabel ? $false : $true
|
||||
[array]$releaseAssets = $release.assets | ForEach-Object { New-AssetItem -ReleaseAsset $_ -Configuration $Configuration }
|
||||
|
||||
$versionsHash.Add($versionKey, [PSCustomObject]@{
|
||||
version = $versionKey
|
||||
stable = $stable
|
||||
release_url = $release.html_url
|
||||
files = $releaseAssets
|
||||
})
|
||||
$versionHash = [PSCustomObject]@{}
|
||||
$versionHash | Add-Member -Name "version" -Value $versionKey -MemberType NoteProperty
|
||||
$versionHash | Add-Member -Name "stable" -Value $stable -MemberType NoteProperty
|
||||
if ($ltsStatus) {
|
||||
$versionHash | Add-Member -Name "lts" -Value $ltsStatus -MemberType NoteProperty
|
||||
}
|
||||
$versionHash | Add-Member -Name "release_url" -Value $release.html_url -MemberType NoteProperty
|
||||
$versionHash | Add-Member -Name "files" -Value $releaseAssets -MemberType NoteProperty
|
||||
$versionsHash.Add($versionKey, $versionHash)
|
||||
}
|
||||
|
||||
# Sort versions by descending
|
||||
return $versionsHash.Values | Sort-Object -Property @{ Expression = { [Semver]$_.version }; Descending = $true }
|
||||
}
|
||||
}
|
||||
|
||||
function Get-LtsRules {
|
||||
param (
|
||||
[Parameter(Mandatory)][object]$Configuration
|
||||
)
|
||||
|
||||
$ruleExpression = $Configuration."lts_rule_expression"
|
||||
if ($ruleExpression) {
|
||||
Invoke-Expression $ruleExpression
|
||||
} else {
|
||||
@()
|
||||
}
|
||||
}
|
||||
|
||||
function Get-VersionLtsStatus {
|
||||
param (
|
||||
[Parameter(Mandatory)][string]$Version,
|
||||
[array]$LtsRules
|
||||
)
|
||||
|
||||
foreach ($ltsRule in $LtsRules) {
|
||||
if (($Version -eq $ltsRule.Name) -or ($Version.StartsWith("$($ltsRule.Name)."))) {
|
||||
return $ltsRule.Value
|
||||
}
|
||||
}
|
||||
|
||||
return $null
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user