New parser for xamarin and python. Reworked workflow with composite actions.

pull/41/head
Maksim Shilov 4 years ago
parent 6f1aa3ce73
commit bffad379d8

@ -0,0 +1,19 @@
name: 'Find new versions'
description: 'Find new versions of a tool'
inputs:
tool-name:
required: true
description: 'Name of a tool to search versions for. Like Xamarin or Python'
default: 'Xamarin'
outputs:
versions-output:
description: "New versions found"
value: ${{ steps.get-new-versions.outputs.versions-output }}
runs:
using: "composite"
steps:
- uses: actions/checkout@v2
- id: get-new-versions
name: Get new versions
shell: pwsh
run: echo "::set-output name=versions-output::$(./get-new-tool-versions/verify-new-tool-version-added-to-image.ps1 -ToolName ${{ inputs.tool-name }})"

@ -0,0 +1,35 @@
name: 'Send Slack notification'
description: 'SendSlack notification about new versions of a tool'
inputs:
url:
required: true
description: 'Slack channel url'
tool-name:
required: true
description: 'Name of a tool to send notification for. Like Xamarin or Python'
default: 'Xamarin'
tool-version:
required: false
description: 'New versions of a tool'
pipeline-url:
required: false
description: 'Url of a pipeline'
image-url:
required: false
description: 'Image url for message'
default: 'https://github.githubassets.com/images/modules/logos_page/GitHub-Mark.png'
text:
required: false
description: 'Message text'
runs:
using: "composite"
steps:
- id: send-slack-notification
name: Send Slack notification
shell: pwsh
run: ./get-new-tool-versions/send-slack-notification.ps1 -Url "${{ inputs.url }}" `
-ToolName "${{ inputs.tool-name }}" `
-ToolVersion "${{ inputs.tool-version }}" `
-PipelineUrl "${{ inputs.pipeline-url }}" `
-ImageUrl "${{ inputs.image-url }}" `
-Text "${{ inputs.text }}"

@ -1,69 +1,87 @@
name: Get Xamarin versions name: Get tools new versions
on: on:
schedule: schedule:
- cron: '0 8 * * THU' - cron: '0 8 * * THU'
workflow_dispatch: workflow_dispatch:
env:
TOOL_NAME: "Xamarin"
defaults: defaults:
run: run:
shell: pwsh shell: pwsh
jobs: jobs:
find_new_versions: find-new-xamarin-versions:
name: Find new versions name: Searching for new Xamarin versions
runs-on: ubuntu-latest runs-on: ubuntu-latest
outputs: outputs:
versions_output: ${{ steps.Get_new_versions.outputs.TOOL_VERSIONS }} versions-output: ${{ steps.get-new-xamarin-versions.outputs.versions-output }}
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v2
- id: get-new-xamarin-versions
uses: ./.github/actions/find-new-tool-versions
with:
tool-name: 'Xamarin'
- id: Get_new_versions check-new-xamarin-versions:
name: Get new versions name: Verifying new Xamarin versions exist
run: ./get-new-tool-versions/get-new-tool-versions.ps1 -ToolName ${{ env.TOOL_NAME }}
check_new_versions:
name: Check new versions
runs-on: ubuntu-latest runs-on: ubuntu-latest
needs: find_new_versions needs: find-new-xamarin-versions
env:
TOOL_VERSIONS: ${{needs.find_new_versions.outputs.versions_output}}
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v2
- name: Check Versions - name: Check Versions
if: success() && env.TOOL_VERSIONS == '' if: needs.find-new-xamarin-versions.outputs.versions-output == ''
run: | run: Write-Host "No new versions found"
Write-Host "No new versions were found" - uses: ./.github/actions/send-slack-notification
Import-Module "./github/github-api.psm1" if: needs.find-new-xamarin-versions.outputs.versions-output != ''
$gitHubApi = Get-GitHubApi -RepositoryFullName "$env:GITHUB_REPOSITORY" ` with:
-AccessToken "${{ secrets.GITHUB_TOKEN }}" url: ${{ secrets.SLACK_CHANNEL_URL }}
tool-name: 'Xamarin'
tool-version: ${{ needs.find-new-xamarin-versions.outputs.versions-output }}
image-url: 'https://avatars.githubusercontent.com/u/790012?s=200&v=4'
- name: Send Slack notification
run: Write-Host "New versions found '${{ needs.find-new-xamarin-versions.outputs.versions-output }}'"
$gitHubApi.CancelWorkflow("$env:GITHUB_RUN_ID") find-new-python-versions:
Start-Sleep -Seconds 60 name: Searching for new Python versions
runs-on: ubuntu-latest
outputs:
versions-output: ${{ steps.get-new-python-versions.outputs.versions-output }}
steps:
- uses: actions/checkout@v2
- id: get-new-python-versions
uses: ./.github/actions/find-new-tool-versions
with:
tool-name: 'Python'
check-new-python-versions:
name: Verifying new Python versions exist
runs-on: ubuntu-latest
needs: find-new-python-versions
steps:
- uses: actions/checkout@v2
- name: Check Versions
if: needs.find-new-python-versions.outputs.versions-output == ''
run: Write-Host "No new versions found"
- uses: ./.github/actions/send-slack-notification
if: needs.find-new-python-versions.outputs.versions-output != ''
with:
url: ${{ secrets.SLACK_CHANNEL_URL }}
tool-name: 'Python'
tool-version: ${{ needs.find-new-python-versions.outputs.versions-output }}
image-url: 'https://avatars.githubusercontent.com/u/790012?s=200&v=4'
- name: Send Slack notification - name: Send Slack notification
run: | run: Write-Host "New versions found '${{ needs.find-new-python-versions.outputs.versions-output }}'"
$message = "The following versions of '${{ env.TOOL_NAME }}' are available, consider adding them to toolset: ${{ env.TOOL_VERSIONS }}"
./get-new-tool-versions/send-slack-notification.ps1 -Url "${{ secrets.SLACK_CHANNEL_URL }}" `
-ToolName "${{ env.TOOL_NAME }}" `
-ImageUrl "https://avatars.githubusercontent.com/u/790012?s=200&v=4" `
-Text "$message"
check_build: check_build:
name: Check build for failures name: Check build for failures
runs-on: ubuntu-latest runs-on: ubuntu-latest
needs: [find_new_versions, check_new_versions] needs: [check-new-xamarin-versions, check-new-python-versions]
if: failure() if: failure()
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v2
- uses: ./.github/actions/send-slack-notification
- name: Send Slack notification if build fails with:
run: | url: ${{ secrets.SLACK_CHANNEL_URL }}
$pipelineUrl = "$env:GITHUB_SERVER_URL/$env:GITHUB_REPOSITORY/actions/runs/$env:GITHUB_RUN_ID" tool-name: 'Xamarin or Python'
$message = "The build of the '${{ env.TOOL_NAME }}' detection pipeline failed :progress-error:\nLink to the pipeline: $pipelineUrl" pipeline-url: '${{ $env:GITHUB_SERVER_URL }}/${{ $env:GITHUB_REPOSITORY }}/actions/runs/${{ $env:GITHUB_RUN_ID }}'
./get-new-tool-versions/send-slack-notification.ps1 -Url "${{ secrets.SLACK_CHANNEL_URL }}" ` image-url: 'https://avatars.githubusercontent.com/u/790012?s=200&v=4'
-ToolName "${{ env.TOOL_NAME }}" ` text: "The build of the Xamarin or Python detection pipeline failed :progress-error:"
-Text "$message" `
-ImageUrl "https://avatars.githubusercontent.com/u/790012?s=200&v=4"

@ -36,7 +36,7 @@ Import-Module $PSScriptRoot/helpers.psm1 -DisableNameChecking
# Create JSON body # Create JSON body
if ([string]::IsNullOrWhiteSpace($Text)) { if ([string]::IsNullOrWhiteSpace($Text)) {
if ($toolName -eq "Xamarin") { if ($toolName -eq ("Xamarin" -or "Python")) {
$Text = "The following versions of '$toolName' are available, consider adding them to toolset: $toolVersion" $Text = "The following versions of '$toolName' are available, consider adding them to toolset: $toolVersion"
} else { } else {
$Text = "The following versions of '$toolName' are available to upload: $toolVersion" $Text = "The following versions of '$toolName' are available to upload: $toolVersion"

@ -0,0 +1,34 @@
<#
.SYNOPSIS
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, Xamarin)
#>
param (
[Parameter(Mandatory)] [string] $ToolName
)
if ($ToolName -eq "Python") {
$builtStableMinorVersionsList = ((Invoke-RestMethod "https://raw.githubusercontent.com/actions/python-versions/main/versions-manifest.json") | Where-Object {$_.stable -eq "True"} | Select-Object -First 10).version | ForEach-Object {$_.split(".")[0,1] -join(".")} | Select-Object -Unique
$existingMinorVesionsList = ((Invoke-RestMethod "https://raw.githubusercontent.com/shilovmaksim/virtual-environments/main/images/win/toolsets/toolset-2019.json").toolcache | Where-Object {$_.name -eq "Python" -and $_.arch -eq "x64"}).versions | ForEach-Object {$_.split(".")[0,1] -join(".")} | Select-Object -Unique
$versionsToAdd = $builtStableMinorVersionsList | Where-Object {$_ -notin $existingMinorVesionsList}
}
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
$uploadedReleases = (Invoke-RestMethod "https://raw.githubusercontent.com/shilovmaksim/virtual-environments/main/images/macos/toolsets/toolset-11.json").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
}
}
return $versionsToAdd
Loading…
Cancel
Save