New parser for xamarin and python. Reworked workflow with composite actions (#41)
parent
6f1aa3ce73
commit
a753279554
@ -0,0 +1,39 @@
|
|||||||
|
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'
|
||||||
|
add-to-toolset-flag:
|
||||||
|
required: false
|
||||||
|
description: 'Flag to use notification for adding new versions to toolset'
|
||||||
|
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 }}" `
|
||||||
|
${{ inputs.add-to-toolset-flag }}
|
@ -0,0 +1,82 @@
|
|||||||
|
name: Get tools new versions
|
||||||
|
on:
|
||||||
|
schedule:
|
||||||
|
- cron: '0 8 * * THU'
|
||||||
|
workflow_dispatch:
|
||||||
|
|
||||||
|
defaults:
|
||||||
|
run:
|
||||||
|
shell: pwsh
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
find-new-xamarin-versions:
|
||||||
|
name: Searching for new Xamarin versions
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
outputs:
|
||||||
|
versions-output: ${{ steps.get-new-xamarin-versions.outputs.versions-output }}
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
- id: get-new-xamarin-versions
|
||||||
|
name: Get new Xamarin versions
|
||||||
|
run: echo "::set-output name=versions-output::$(./get-new-tool-versions/verify-new-tool-version-added-to-image.ps1 -ToolName Xamarin)"
|
||||||
|
|
||||||
|
check-new-xamarin-versions:
|
||||||
|
name: Verifying new Xamarin versions exist
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
needs: find-new-xamarin-versions
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
- name: Check Versions
|
||||||
|
if: needs.find-new-xamarin-versions.outputs.versions-output == ''
|
||||||
|
run: Write-Host "No new versions found"
|
||||||
|
- uses: ./.github/actions/send-slack-notification
|
||||||
|
if: needs.find-new-xamarin-versions.outputs.versions-output != ''
|
||||||
|
with:
|
||||||
|
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'
|
||||||
|
add-to-toolset-flag: '-AddToToolsetFlag'
|
||||||
|
|
||||||
|
find-new-python-versions:
|
||||||
|
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
|
||||||
|
name: Get new Python versions
|
||||||
|
run: echo "::set-output name=versions-output::$(./get-new-tool-versions/verify-new-tool-version-added-to-image.ps1 -ToolName 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://www.python.org/static/community_logos/python-powered-h-100x130.png'
|
||||||
|
add-to-toolset-flag: '-AddToToolsetFlag'
|
||||||
|
|
||||||
|
check_build:
|
||||||
|
name: Check build for failures
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
needs: [check-new-xamarin-versions, check-new-python-versions]
|
||||||
|
if: failure()
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
- uses: ./.github/actions/send-slack-notification
|
||||||
|
with:
|
||||||
|
url: ${{ secrets.SLACK_CHANNEL_URL }}
|
||||||
|
tool-name: 'Python or Xamarin'
|
||||||
|
pipeline-url: '$env:GITHUB_SERVER_URL/$env:GITHUB_REPOSITORY/actions/runs/$env:GITHUB_RUN_ID'
|
||||||
|
text: "The build of the Xamarin or Python detection pipeline has failed stages:"
|
@ -1,69 +0,0 @@
|
|||||||
name: Get Xamarin versions
|
|
||||||
on:
|
|
||||||
schedule:
|
|
||||||
- cron: '0 8 * * THU'
|
|
||||||
workflow_dispatch:
|
|
||||||
|
|
||||||
env:
|
|
||||||
TOOL_NAME: "Xamarin"
|
|
||||||
defaults:
|
|
||||||
run:
|
|
||||||
shell: pwsh
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
find_new_versions:
|
|
||||||
name: Find new versions
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
outputs:
|
|
||||||
versions_output: ${{ steps.Get_new_versions.outputs.TOOL_VERSIONS }}
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v2
|
|
||||||
|
|
||||||
- id: Get_new_versions
|
|
||||||
name: Get new versions
|
|
||||||
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
|
|
||||||
needs: find_new_versions
|
|
||||||
env:
|
|
||||||
TOOL_VERSIONS: ${{needs.find_new_versions.outputs.versions_output}}
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v2
|
|
||||||
|
|
||||||
- name: Check Versions
|
|
||||||
if: success() && env.TOOL_VERSIONS == ''
|
|
||||||
run: |
|
|
||||||
Write-Host "No new versions were found"
|
|
||||||
Import-Module "./github/github-api.psm1"
|
|
||||||
$gitHubApi = Get-GitHubApi -RepositoryFullName "$env:GITHUB_REPOSITORY" `
|
|
||||||
-AccessToken "${{ secrets.GITHUB_TOKEN }}"
|
|
||||||
|
|
||||||
$gitHubApi.CancelWorkflow("$env:GITHUB_RUN_ID")
|
|
||||||
Start-Sleep -Seconds 60
|
|
||||||
|
|
||||||
- name: Send Slack notification
|
|
||||||
run: |
|
|
||||||
$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:
|
|
||||||
name: Check build for failures
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
needs: [find_new_versions, check_new_versions]
|
|
||||||
if: failure()
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v2
|
|
||||||
|
|
||||||
- name: Send Slack notification if build fails
|
|
||||||
run: |
|
|
||||||
$pipelineUrl = "$env:GITHUB_SERVER_URL/$env:GITHUB_REPOSITORY/actions/runs/$env:GITHUB_RUN_ID"
|
|
||||||
$message = "The build of the '${{ env.TOOL_NAME }}' detection pipeline failed :progress-error:\nLink to the pipeline: $pipelineUrl"
|
|
||||||
./get-new-tool-versions/send-slack-notification.ps1 -Url "${{ secrets.SLACK_CHANNEL_URL }}" `
|
|
||||||
-ToolName "${{ env.TOOL_NAME }}" `
|
|
||||||
-Text "$message" `
|
|
||||||
-ImageUrl "https://avatars.githubusercontent.com/u/790012?s=200&v=4"
|
|
@ -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
|
Loading…
Reference in New Issue