Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 14 additions & 4 deletions tools/devops/automation/scripts/GitHub.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,7 @@ function New-GitHubSummaryComment {
$TestSummaryPath,

[string]
$Artifacts
$Artifacts=""
)

$envVars = @{
Expand Down Expand Up @@ -410,20 +410,28 @@ function New-GitHubSummaryComment {
# we did generate an index with the files in vsdrops
$sb.AppendLine("* [Html Report (VSDrops)]($Env:VSDROPS_INDEX)")
}
if ($Artifacts) {
if (-not [string]::IsNullOrEmpty($Artifacts)) {
Write-Host "Parsing artifacts"
if (-not (Test-Path $Artifacts -PathType Leaf)) {
$sb.AppendLine("Path $Artifacts was not found!")
} else {
# read the json file, convert it to an object and add a line for each artifact
$json = Get-Content $Artifacts | ConvertFrom-Json
if ($json.Count -gt 0) {
$sb.AppendLine("<details><summary>View packages</summary>")
$sb.AppendLine("") # no new line results in a bad rendering in the links
foreach ($a in $json) {
$url = $a.url
if ($url.EndsWith(".pkg") -or $url.EndsWith(".nupkg")) {
try {
$fileName = $a.url.Substring($a.url.LastIndexOf("/" + 1))
$sb.AppendLine("* [$fileName]($($a.url))")
$fileName = $a.url.Substring($a.url.LastIndexOf("/") + 1)
Write-Host "Adding link for $fileName"
if ($a.url.Contains("notarized")) {
$link = "* [$fileName (notarized)]($($a.url))"
} else {
$link = "* [$fileName]($($a.url))"
}
$sb.AppendLine($link)
} catch {
Write-Host "Could not get file name for url $url"
}
Expand All @@ -434,6 +442,8 @@ function New-GitHubSummaryComment {
$sb.AppendLine("No packages found.")
}
}
} else {
Write-Host "Artifacts were not provided."
}

$headerLinks = $sb.ToString()
Expand Down
6 changes: 5 additions & 1 deletion tools/devops/automation/templates/build/publish-html.yml
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,11 @@ steps:
$env:VSDROPS_INDEX="$Env:VSDROPSPREFIX/$Env:BUILD_BUILDNUMBER/$Env:BUILD_BUILDID/$Env:DEVICE_PREFIX/;/tests/vsdrops_index.html"
Import-Module $Env:SYSTEM_DEFAULTWORKINGDIRECTORY\xamarin-macios\tools\devops\automation\scripts\GitHub.psm1
Import-Module $Env:SYSTEM_DEFAULTWORKINGDIRECTORY\xamarin-macios\tools\devops\automation\scripts\VSTS.psm1
if ($Env:BUILD_PACKAGE -eq "True") {

$buildReason = "$(Build.Reason)"
$buildSourceBranchName = "$(Build.SourceBranchName)"

if ($buildReason -ne "PullRequest" -or $Env:BUILD_PACKAGE -eq "True") {
Write-Host "Json path is $Env:ARTIFACTS_JSON_PATH"
$response = New-GitHubSummaryComment -Context "$Env:CONTEXT" -TestSummaryPath "$Env:TESTS_SUMMARY" -Artifacts "$Env:ARTIFACTS_JSON_PATH"
Write-Host $response
Expand Down