Migrate tools CI to GA
parent
68072bedef
commit
7a56615638
@ -1,29 +1,15 @@
|
||||
steps:
|
||||
- checkout: self
|
||||
|
||||
- task: PowerShell@2
|
||||
displayName: 'Get source version'
|
||||
inputs:
|
||||
TargetType: inline
|
||||
script: |
|
||||
$url = "https://api.github.com/repos/$(REPOSITORY)/commits/$(BRANCH)"
|
||||
$commit = Invoke-RestMethod -Uri $url -Method "GET"
|
||||
Write-Output "##vso[task.setvariable variable=COMMIT_SHA]$($commit.sha)"
|
||||
|
||||
- task: PowerShell@2
|
||||
displayName: 'Run builds'
|
||||
inputs:
|
||||
targetType: filePath
|
||||
filePath: './azure-devops/run-ci-builds.ps1'
|
||||
filePath: './github/run-ci-builds.ps1'
|
||||
arguments: |
|
||||
-TeamFoundationCollectionUri $(System.TeamFoundationCollectionUri) `
|
||||
-AzureDevOpsProjectName $(System.TeamProject) `
|
||||
-AzureDevOpsAccessToken $(System.AccessToken) `
|
||||
-SourceBranch $(BRANCH) `
|
||||
-DefinitionId $(DEFINITION_ID) `
|
||||
-SourceVersion $(COMMIT_SHA) `
|
||||
-ManifestLink $(MANIFEST_URL) `
|
||||
-WaitForBuilds $(WAIT_FOR_BUILDS) `
|
||||
-RepositoryFullName $(REPOSITORY_FULL_NAME) `
|
||||
-AccessToken $(GITHUB_TOKEN) `
|
||||
-WorkflowFileName $(WORKFLOW_FILE_NAME) `
|
||||
-WorkflowDispatchRef $(DISPATCH_REF) `
|
||||
-ToolVersions "$(ToolVersions)" `
|
||||
-RetryIntervalSec $(INTERVAL_SEC) `
|
||||
-RetryCount $(RETRY_COUNT)
|
||||
-PublishReleases $(PUPLISH_RELEASES)
|
@ -0,0 +1,91 @@
|
||||
<#
|
||||
.SYNOPSIS
|
||||
Trigger runs on the workflow_dispatch event to build and upload tool packages
|
||||
|
||||
.PARAMETER RepositoryFullName
|
||||
Required parameter. The owner and repository name. For example, 'actions/versions-package-tools'
|
||||
.PARAMETER AccessToken
|
||||
Required parameter. PAT Token to authorize
|
||||
.PARAMETER WorkflowFileName
|
||||
Required parameter. The name of workflow file that will be triggered
|
||||
.PARAMETER WorkflowDispatchRef
|
||||
Required parameter. The reference of the workflow run. The reference can be a branch, tag, or a commit SHA.
|
||||
.PARAMETER ToolVersions
|
||||
Required parameter. List of tool versions to build and upload
|
||||
.PARAMETER PublishReleases
|
||||
Required parameter. Whether to publish releases, true or false
|
||||
#>
|
||||
|
||||
param (
|
||||
[Parameter(Mandatory)] [string] $RepositoryFullName,
|
||||
[Parameter(Mandatory)] [string] $AccessToken,
|
||||
[Parameter(Mandatory)] [string] $WorkflowFileName,
|
||||
[Parameter(Mandatory)] [string] $WorkflowDispatchRef,
|
||||
[Parameter(Mandatory)] [string] $ToolVersions,
|
||||
[Parameter(Mandatory)] [string] $PublishReleases
|
||||
)
|
||||
|
||||
Import-Module (Join-Path $PSScriptRoot "github-api.psm1")
|
||||
|
||||
function Get-WorkflowRunLink {
|
||||
param(
|
||||
[Parameter(Mandatory)] [object] $GitHubApi,
|
||||
[Parameter(Mandatory)] [string] $WorkflowFileName,
|
||||
[Parameter(Mandatory)] [string] $ToolVersion
|
||||
)
|
||||
|
||||
$listWorkflowRuns = $GitHubApi.GetWorkflowRuns($WorkflowFileName).workflow_runs | Sort-Object -Property 'run_number' -Descending
|
||||
|
||||
foreach ($workflowRun in $listWorkflowRuns) {
|
||||
$workflowRunJob = $gitHubApi.GetWorkflowRunJobs($workflowRun.id).jobs | Select-Object -First 1
|
||||
|
||||
if ($workflowRunJob.name -match $ToolVersion) {
|
||||
return $workflowRun.html_url
|
||||
}
|
||||
}
|
||||
|
||||
return $null
|
||||
}
|
||||
|
||||
function Queue-Builds {
|
||||
param (
|
||||
[Parameter(Mandatory)] [object] $GitHubApi,
|
||||
[Parameter(Mandatory)] [string] $ToolVersions,
|
||||
[Parameter(Mandatory)] [string] $WorkflowFileName,
|
||||
[Parameter(Mandatory)] [string] $WorkflowDispatchRef,
|
||||
[Parameter(Mandatory)] [string] $PublishReleases
|
||||
)
|
||||
|
||||
$inputs = @{
|
||||
PUBLISH_RELEASES = $PublishReleases
|
||||
}
|
||||
|
||||
$ToolVersions.Split(',') | ForEach-Object {
|
||||
$version = $_.Trim()
|
||||
$inputs.VERSION = $version
|
||||
|
||||
Write-Host "Queue build for $version..."
|
||||
$GitHubApi.CreateWorkflowDispatch($WorkflowFileName, $WorkflowDispatchRef, $inputs)
|
||||
|
||||
Start-Sleep -s 10
|
||||
$workflowRunLink = Get-WorkflowRunLink -GitHubApi $GitHubApi `
|
||||
-WorkflowFileName $WorkflowFileName `
|
||||
-ToolVersion $version
|
||||
|
||||
if (-not $workflowRunLink) {
|
||||
Write-Host "Could not find build for $version..."
|
||||
exit 1
|
||||
}
|
||||
|
||||
Write-Host "Link to the build: $workflowRunLink"
|
||||
}
|
||||
}
|
||||
|
||||
$gitHubApi = Get-GitHubApi -RepositoryFullName $RepositoryFullName -AccessToken $AccessToken
|
||||
|
||||
Write-Host "Versions to build: $ToolVersions"
|
||||
Queue-Builds -GitHubApi $gitHubApi `
|
||||
-ToolVersions $ToolVersions `
|
||||
-WorkflowFileName $WorkflowFileName `
|
||||
-WorkflowDispatchRef $WorkflowDispatchRef `
|
||||
-PublishReleases $PublishReleases
|
Loading…
Reference in New Issue