From 35f02e1fa725dc7aaf04ded1e3b93acf979d8e9d Mon Sep 17 00:00:00 2001 From: "FAREAST\\chunyu" Date: Thu, 24 Oct 2024 16:13:16 +0800 Subject: [PATCH 1/3] skip last line of breaking change log --- eng/scripts/automation/GenerateAndBuildLib.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eng/scripts/automation/GenerateAndBuildLib.ps1 b/eng/scripts/automation/GenerateAndBuildLib.ps1 index 1bec3c7e9bed5..0927f2ac7517c 100644 --- a/eng/scripts/automation/GenerateAndBuildLib.ps1 +++ b/eng/scripts/automation/GenerateAndBuildLib.ps1 @@ -856,7 +856,7 @@ function GeneratePackage() $hasBreakingChange = $false } else { - $logFile = Get-Content -Path $logFilePath | select-object -skip 2 + $logFile = Get-Content -Path $logFilePath | select-object -SkipLast 1 $breakingChanges = $logFile -join ",`n" $content = "Breaking Changes: $breakingChanges" $hasBreakingChange = $true From 3a1ef6e5b41e166723ce93652e44345e17d76395 Mon Sep 17 00:00:00 2001 From: "FAREAST\\chunyu" Date: Fri, 25 Oct 2024 13:55:33 +0800 Subject: [PATCH 2/3] add log --- eng/scripts/automation/GenerateAndBuildLib.ps1 | 1 + 1 file changed, 1 insertion(+) diff --git a/eng/scripts/automation/GenerateAndBuildLib.ps1 b/eng/scripts/automation/GenerateAndBuildLib.ps1 index 0927f2ac7517c..1e536173f71b7 100644 --- a/eng/scripts/automation/GenerateAndBuildLib.ps1 +++ b/eng/scripts/automation/GenerateAndBuildLib.ps1 @@ -856,6 +856,7 @@ function GeneratePackage() $hasBreakingChange = $false } else { + Write-Host "Breaking changes detected in the build log." $logFile = Get-Content -Path $logFilePath | select-object -SkipLast 1 $breakingChanges = $logFile -join ",`n" $content = "Breaking Changes: $breakingChanges" From 37b7cbe29684a1be107f98b37cd9168efe1b0cd7 Mon Sep 17 00:00:00 2001 From: "FAREAST\\chunyu" Date: Fri, 25 Oct 2024 15:59:20 +0800 Subject: [PATCH 3/3] retrieve breaking change from log --- eng/scripts/automation/GenerateAndBuildLib.ps1 | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/eng/scripts/automation/GenerateAndBuildLib.ps1 b/eng/scripts/automation/GenerateAndBuildLib.ps1 index 1e536173f71b7..95e094d52312d 100644 --- a/eng/scripts/automation/GenerateAndBuildLib.ps1 +++ b/eng/scripts/automation/GenerateAndBuildLib.ps1 @@ -747,6 +747,7 @@ function GeneratePackage() $artifacts = @() $apiViewArtifact = "" $hasBreakingChange = $false + $breakingChangeItems = @() $content = "" $result = "succeeded" $isGenerateSuccess = $true @@ -858,7 +859,13 @@ function GeneratePackage() else { Write-Host "Breaking changes detected in the build log." $logFile = Get-Content -Path $logFilePath | select-object -SkipLast 1 - $breakingChanges = $logFile -join ",`n" + $regex = "error( ?):( ?)(?.*) .*\[" + foreach ($line in $logFile) { + if ($line -match $regex) { + $breakingChangeItems += $matches["breakingChange"] + } + } + $breakingChanges = $breakingChangeItems -join ",`n" $content = "Breaking Changes: $breakingChanges" $hasBreakingChange = $true } @@ -872,6 +879,7 @@ function GeneratePackage() $changelog = [PSCustomObject]@{ content = $content hasBreakingChange = $hasBreakingChange + breakingChangeItems = $breakingChangeItems } $ciFilePath = "sdk/$service/ci.yml"