diff --git a/.github/workflows/promote-shipped-apis.yml b/.github/workflows/promote-shipped-apis.yml index fb4d44ffe41..5fd5290a236 100644 --- a/.github/workflows/promote-shipped-apis.yml +++ b/.github/workflows/promote-shipped-apis.yml @@ -79,9 +79,11 @@ jobs: git checkout $prBranch git merge origin/$branch -m "Merge $branch into promote-shipped-apis branch" - - name: Run public API promotion script - shell: pwsh - run: ./dotnet/eng/scripts/promote-shipped-apis.ps1 + - name: Promote public API exports + id: promote + uses: BinkyLabs/public-api-promote@724e672702a3e55a06e4b1355183397d44f9f390 # v1.0.3 + with: + unshipped-glob: 'dotnet/src/**/*.Unshipped.txt' - name: Check for changes id: check_changes diff --git a/dotnet/eng/scripts/promote-shipped-apis.ps1 b/dotnet/eng/scripts/promote-shipped-apis.ps1 deleted file mode 100644 index f7140452f2f..00000000000 --- a/dotnet/eng/scripts/promote-shipped-apis.ps1 +++ /dev/null @@ -1,54 +0,0 @@ -param( - [string] $Path = (Join-Path $PSScriptRoot '..\..\src') -) - -$ErrorActionPreference = 'Stop' - -$root = Resolve-Path $Path -$encoding = [System.Text.UTF8Encoding]::new($true) -$nullableHeader = '#nullable enable' -$promotedFiles = 0 -$promotedApis = 0 - -Get-ChildItem -Path $root -Recurse -Filter 'PublicAPI.Unshipped.txt' | ForEach-Object { - $unshippedFile = $_.FullName - $shippedFile = Join-Path $_.DirectoryName 'PublicAPI.Shipped.txt' - - $unshippedLines = if ((Get-Item $unshippedFile).Length -gt 0) { - Get-Content -Path $unshippedFile -Encoding UTF8 | Where-Object { - -not [string]::IsNullOrWhiteSpace($_) -and $_ -ne $nullableHeader - } - } - else { - @() - } - - if ($unshippedLines.Count -eq 0) { - return - } - - $allLines = [System.Collections.Generic.SortedSet[string]]::new([System.StringComparer]::Ordinal) - if (Test-Path $shippedFile) { - Get-Content -Path $shippedFile -Encoding UTF8 | Where-Object { - -not [string]::IsNullOrWhiteSpace($_) -and $_ -ne $nullableHeader - } | ForEach-Object { - $null = $allLines.Add($_) - } - } - - $unshippedLines | ForEach-Object { - $null = $allLines.Add($_) - } - - $shippedLines = @($nullableHeader) + @($allLines) - $shippedContent = [string]::Join("`n", $shippedLines) + "`n" - - [System.IO.File]::WriteAllText($shippedFile, $shippedContent, $encoding) - [System.IO.File]::WriteAllText($unshippedFile, "$nullableHeader`n", $encoding) - - $promotedFiles++ - $promotedApis += $unshippedLines.Count - Write-Host "Promoted $($unshippedLines.Count) public API entries in $($_.Directory.Name)." -} - -Write-Host "Promoted $promotedApis public API baseline entries across $promotedFiles baseline file(s)."