From c0c25a6bdc3816778e6822037d719b909abc9e74 Mon Sep 17 00:00:00 2001 From: Mikel Blanchard Date: Fri, 7 Jun 2024 13:40:00 -0700 Subject: [PATCH 01/10] Port tweaks and improvements to release automation from the main repo. --- .github/workflows/automation.yml | 2 +- .github/workflows/publish-packages.yml | 14 +++++++++++++- build/scripts/post-release.psm1 | 7 ++++--- build/scripts/prepare-release.psm1 | 2 +- 4 files changed, 19 insertions(+), 6 deletions(-) diff --git a/.github/workflows/automation.yml b/.github/workflows/automation.yml index e85a3720ab..1385474892 100644 --- a/.github/workflows/automation.yml +++ b/.github/workflows/automation.yml @@ -13,7 +13,7 @@ on: value: ${{ vars.AUTOMATION_EMAIL }} secrets: OPENTELEMETRYBOT_GITHUB_TOKEN: - required: true + required: false jobs: resolve-automation: diff --git a/.github/workflows/publish-packages.yml b/.github/workflows/publish-packages.yml index 84d492fcff..f9cae34b57 100644 --- a/.github/workflows/publish-packages.yml +++ b/.github/workflows/publish-packages.yml @@ -26,6 +26,7 @@ jobs: outputs: artifact-url: ${{ steps.upload-artifacts.outputs.artifact-url }} + artifact-id: ${{ steps.upload-artifacts.outputs.artifact-id }} steps: - uses: actions/checkout@v4 @@ -120,6 +121,16 @@ jobs: with: token: ${{ secrets[needs.automation.outputs.token-secret-name] }} + - name: Download Artifacts + run: | + curl \ + -H "Accept: application/vnd.github+json" \ + -H "Authorization: token ${{ github.token }}" \ + -L \ + -o '${{ github.workspace }}/artifacts/${{ github.ref_name }}-packages.zip' \ + --create-dirs \ + "https://api.github.com/repos/${{ github.repository }}/actions/artifacts/${{ needs.build-pack-publish.outputs.artifact-id }}/zip" + - name: Create GitHub Release if: github.ref_type == 'tag' shell: pwsh @@ -128,7 +139,8 @@ jobs: CreateRelease ` -gitRepository '${{ github.repository }}' ` - -tag '${{ github.ref_name }}' + -tag '${{ github.ref_name }}' ` + -releaseFiles '${{ github.workspace }}/artifacts/${{ github.ref_name }}-packages.zip#Packages' - name: Post notice when packages are ready shell: pwsh diff --git a/build/scripts/post-release.psm1 b/build/scripts/post-release.psm1 index 0e5c6bc2b4..f7897dc1f8 100644 --- a/build/scripts/post-release.psm1 +++ b/build/scripts/post-release.psm1 @@ -1,7 +1,8 @@ function CreateRelease { param( [Parameter(Mandatory=$true)][string]$gitRepository, - [Parameter(Mandatory=$true)][string]$tag + [Parameter(Mandatory=$true)][string]$tag, + [Parameter()][string]$releaseFiles ) $match = [regex]::Match($tag, '^(.*?-)(.*)$') @@ -69,7 +70,7 @@ $content if ($version -match '-alpha' -or $version -match '-beta' -or $version -match '-rc') { - gh release create $tag ` + gh release create $tag $releaseFiles ` --title $tag ` --verify-tag ` --notes $notes ` @@ -77,7 +78,7 @@ $content } else { - gh release create $tag ` + gh release create $tag $releaseFiles ` --title $tag ` --verify-tag ` --notes $notes ` diff --git a/build/scripts/prepare-release.psm1 b/build/scripts/prepare-release.psm1 index 0db3cca47e..509b9393f8 100644 --- a/build/scripts/prepare-release.psm1 +++ b/build/scripts/prepare-release.psm1 @@ -109,7 +109,7 @@ function LockPullRequestAndPostNoticeToCreateReleaseTag { @" I noticed this PR was merged. -Post a comment with "/CreateReleaseTag" in the body if you would like me to create the release tag ``$tag`` for [the merge commit](https://github.com/$gitRepository/commit/$commit) and then trigger the package workflow. +Post a comment with "/CreateReleaseTag" in the body if you would like me to create the release tag ``$tag`` for [the merge commit](https://github.com/$gitRepository/commit/$commit) which will trigger the package workflow. "@ gh pr comment $pullRequestNumber --body $body From 174dac85c72be296cf6ff47d60395a532488ba07 Mon Sep 17 00:00:00 2001 From: Mikel Blanchard Date: Fri, 7 Jun 2024 21:24:25 -0700 Subject: [PATCH 02/10] Use release naming in automation. --- .github/workflows/prepare-release.yml | 4 ++-- build/scripts/post-release.psm1 | 10 +++++----- build/scripts/prepare-release.psm1 | 8 ++++---- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/.github/workflows/prepare-release.yml b/.github/workflows/prepare-release.yml index 0098bc82ed..eea3b61943 100644 --- a/.github/workflows/prepare-release.yml +++ b/.github/workflows/prepare-release.yml @@ -106,7 +106,7 @@ jobs: && github.event.action == 'closed' && github.event.pull_request.user.login == needs.automation.outputs.username && github.event.pull_request.merged == true - && startsWith(github.event.pull_request.title, '[repo] Prepare release ') + && startsWith(github.event.pull_request.title, '[release] Prepare release ') && needs.automation.outputs.enabled env: @@ -139,7 +139,7 @@ jobs: && github.event.issue.locked == true && github.event.comment.user.login != needs.automation.outputs.username && contains(github.event.comment.body, '/CreateReleaseTag') - && startsWith(github.event.issue.title, '[repo] Prepare release ') + && startsWith(github.event.issue.title, '[release] Prepare release ') && github.event.issue.pull_request.merged_at && needs.automation.outputs.enabled diff --git a/build/scripts/post-release.psm1 b/build/scripts/post-release.psm1 index f7897dc1f8..ab786058e5 100644 --- a/build/scripts/post-release.psm1 +++ b/build/scripts/post-release.psm1 @@ -107,7 +107,7 @@ function TryPostPackagesReadyNoticeOnPrepareReleasePullRequest { foreach ($pr in $prListResponse) { - if ($pr.author.login -ne $botUserName -or $pr.title -ne "[repo] Prepare release $tag") + if ($pr.author.login -ne $botUserName -or $pr.title -ne "[release] Prepare release $tag") { continue } @@ -250,11 +250,11 @@ Merge once packages are available on NuGet and the build passes. "@ gh pr create ` - --title "[repo] $tagPrefix stable release $version updates" ` + --title "[release] $tagPrefix stable release $version updates" ` --body $body ` --base $targetBranch ` --head $branch ` - --label infra + --label release } Export-ModuleMember -Function CreatePackageValidationBaselineVersionUpdatePullRequest @@ -363,11 +363,11 @@ Merge once packages are available on NuGet and the build passes. "@ $createPullRequestResponse = gh pr create ` - --title "[repo] Core release $version updates" ` + --title "[release] Core release $version updates" ` --body $body ` --base $targetBranch ` --head $branch ` - --label infra + --label release $match = [regex]::Match($createPullRequestResponse, "\/pull\/(.*)$") if ($match.Success -eq $false) diff --git a/build/scripts/prepare-release.psm1 b/build/scripts/prepare-release.psm1 index 509b9393f8..f567987878 100644 --- a/build/scripts/prepare-release.psm1 +++ b/build/scripts/prepare-release.psm1 @@ -68,11 +68,11 @@ Note: This PR was opened automatically by the [prepare release workflow](https:/ } gh pr create ` - --title "[repo] Prepare release $tag" ` + --title "[release] Prepare release $tag" ` --body $body ` --base $targetBranch ` --head $branch ` - --label infra + --label release } Export-ModuleMember -Function CreatePullRequestToUpdateChangelogsAndPublicApis @@ -91,7 +91,7 @@ function LockPullRequestAndPostNoticeToCreateReleaseTag { throw 'PR author was unexpected' } - $match = [regex]::Match($prViewResponse.title, '^\[repo\] Prepare release (.*)$') + $match = [regex]::Match($prViewResponse.title, '^\[release\] Prepare release (.*)$') if ($match.Success -eq $false) { throw 'Could not parse tag from PR title' @@ -135,7 +135,7 @@ function CreateReleaseTagAndPostNoticeOnPullRequest { throw 'PR author was unexpected' } - $match = [regex]::Match($prViewResponse.title, '^\[repo\] Prepare release (.*)$') + $match = [regex]::Match($prViewResponse.title, '^\[release\] Prepare release (.*)$') if ($match.Success -eq $false) { throw 'Could not parse tag from PR title' From 21226665f3dd16af739db5f2e7494a783aabb333 Mon Sep 17 00:00:00 2001 From: Mikel Blanchard Date: Sun, 9 Jun 2024 22:32:07 -0700 Subject: [PATCH 03/10] Port add labels changes from main repo. --- .github/workflows/add-labels.yml | 40 +++++++-- build/scripts/add-labels.ps1 | 12 --- build/scripts/add-labels.psm1 | 148 +++++++++++++++++++++++++++++++ opentelemetry-dotnet-contrib.sln | 2 +- 4 files changed, 183 insertions(+), 19 deletions(-) delete mode 100644 build/scripts/add-labels.ps1 create mode 100644 build/scripts/add-labels.psm1 diff --git a/.github/workflows/add-labels.yml b/.github/workflows/add-labels.yml index 9c040eaaab..af7f97abcf 100644 --- a/.github/workflows/add-labels.yml +++ b/.github/workflows/add-labels.yml @@ -1,16 +1,21 @@ -name: 'Add labels for component found in bug issue descriptions' +name: 'Add labels to issues and pull requests' on: issues: - types: [opened] + types: [ opened ] + + pull_request: + branches: [ 'main*', 'instrumentation*', 'exporter*', 'extensions*' ] permissions: issues: write + pull-requests: write jobs: - add-labels: - if: ${{ !github.event.issue.pull_request }} + add-labels-on-issues: + if: github.event_name == 'issues' && !github.event.issue.pull_request runs-on: ubuntu-latest + steps: - name: check out code uses: actions/checkout@v4 @@ -18,8 +23,31 @@ jobs: - name: Add labels for component found in bug issue descriptions shell: pwsh run: | - .\build\scripts\add-labels.ps1 -issueNumber $env:ISSUE_NUMBER -issueBody $env:ISSUE_BODY + Import-Module .\build\scripts\add-labels.psm1 + + AddLabelsOnIssuesForComponentFoundInBody ` + -issueNumber ${{ github.event.issue.number }} ` + -issueBody $env:ISSUE_BODY env: GH_TOKEN: ${{ github.token }} - ISSUE_NUMBER: ${{ github.event.issue.number }} ISSUE_BODY: ${{ github.event.issue.body }} + + add-labels-on-pull-requests: + if: github.event_name == 'pull_request' + + runs-on: ubuntu-latest + + steps: + - name: check out code + uses: actions/checkout@v4 + + - name: Add labels for files changed on pull requests + shell: pwsh + run: | + Import-Module .\build\scripts\add-labels.psm1 + + AddLabelsOnPullRequestsBasedOnFilesChanged ` + -pullRequestNumber ${{ github.event.pull_request.number }} ` + -labelPackagePrefix 'pkg:' + env: + GH_TOKEN: ${{ github.token }} diff --git a/build/scripts/add-labels.ps1 b/build/scripts/add-labels.ps1 deleted file mode 100644 index 7d72236c11..0000000000 --- a/build/scripts/add-labels.ps1 +++ /dev/null @@ -1,12 +0,0 @@ -param( - [Parameter(Mandatory=$true)][int]$issueNumber, - [Parameter(Mandatory=$true)][string]$issueBody -) - -$match = [regex]::Match($issueBody, '^[#]+ Component\s*OpenTelemetry\.((?:.|\w+)+)') -if ($match.Success -eq $false) -{ - Return -} - -gh issue edit $issueNumber --add-label $("comp:" + $match.Groups[1].Value.ToLower()) diff --git a/build/scripts/add-labels.psm1 b/build/scripts/add-labels.psm1 new file mode 100644 index 0000000000..a064b150be --- /dev/null +++ b/build/scripts/add-labels.psm1 @@ -0,0 +1,148 @@ +function AddLabelsOnIssuesForComponentFoundInBody { + param( + [Parameter(Mandatory=$true)][int]$issueNumber, + [Parameter(Mandatory=$true)][string]$issueBody + ) + + $match = [regex]::Match($issueBody, '^[#]+ Component\s*OpenTelemetry\.((?:.|\w+)+)') + if ($match.Success -eq $false) + { + Return + } + + gh issue edit $issueNumber --add-label $("comp:" + $match.Groups[1].Value.ToLower()) +} + +Export-ModuleMember -Function AddLabelsOnIssuesForComponentFoundInBody + +function AddLabelsOnPullRequestsBasedOnFilesChanged { + param( + [Parameter(Mandatory=$true)][int]$pullRequestNumber, + [Parameter(Mandatory=$true)][string]$labelPackagePrefix # 'pkg:' on main repo, 'comp:' on contrib repo + ) + + # Note: This function is intended to work on main repo and on contrib. Please + # keep them in sync. + + $repoLabels = gh label list --json name,id | ConvertFrom-Json + + $filesChangedOnPullRequest = gh pr diff $pullRequestNumber --name-only + + $labelsOnPullRequest = (gh pr view $pullRequestNumber --json labels | ConvertFrom-Json).labels + + $visitedProjects = New-Object System.Collections.Generic.HashSet[string] + $labelsToAdd = New-Object System.Collections.Generic.HashSet[string] + $labelsToRemove = New-Object System.Collections.Generic.HashSet[string] + + # Note: perf label may be added but it is kind of a guess so we don't remove + # it automatically in order to also allow manual inclusion after reviewing files + $managedLabels = 'infra', 'documentation', 'dependencies' + $rootInfraFiles = 'global.json', 'NuGet.config', 'codeowners' + $documentationFiles = 'readme.md', 'contributing.md', 'releasing.md', 'versioning.md' + + foreach ($fileChanged in $filesChangedOnPullRequest) + { + $fileChanged = $fileChanged.ToLower() + $fullFileName = [System.IO.Path]::GetFileName($fileChanged) + $fileName = [System.IO.Path]::GetFileNameWithoutExtension($fileChanged) + $fileExtension = [System.IO.Path]::GetExtension($fileChanged) + + if ($fileChanged.StartsWith('src/') -or $fileChanged.StartsWith('test/')) + { + $match = [regex]::Match($fileChanged, '^(?:(?:src)|(?:test))\/(.*?)\/.+$') + if ($match.Success -eq $false) + { + continue + } + $rawProjectName = $match.Groups[1].Value + if ($rawProjectName.Contains(".benchmarks") -or $rawProjectName.Contains(".stress")) + { + $added = $labelsToAdd.Add("perf") + } + + $projectName = $rawProjectName.Replace(".tests", "").Replace(".benchmarks", "").Replace(".stress", "") + if ($visitedProjects.Contains($projectName)) + { + continue + } + + $added = $visitedProjects.Add($projectName); + + foreach ($repoLabel in $repoLabels) + { + if ($repoLabel.name.StartsWith($labelPackagePrefix)) + { + $package = $repoLabel.name.Substring($labelPackagePrefix.Length).ToLower() + if ($package.StartsWith('opentelemetry') -eq $false) + { + # Note: On contrib labels don't have "OpenTelemetry." prefix + $package = 'opentelemetry.' + $package + } + if ($package -eq $projectName) + { + $added = $labelsToAdd.Add($repoLabel.name) + break + } + } + } + } + + if ($documentationFiles.Contains($fullFileName) -or + $fileChanged.StartsWith('docs/') -or + $fileChanged.StartsWith('examples/')) + { + $added = $labelsToAdd.Add("documentation") + } + + if ($fileChanged.StartsWith('build/') -or + $fileChanged.StartsWith('.github/') -or + $rootInfraFiles.Contains($fullFileName) -or + $fileExtension -eq ".props" -or + $fileExtension -eq ".targets" -or + $fileChanged.StartsWith('test\openTelemetry.aotcompatibility')) + { + $added = $labelsToAdd.Add("infra") + } + + if ($fileChanged.StartsWith('test\benchmarks')) + { + $added = $labelsToAdd.Add("perf") + } + + if ($fullFileName -eq 'directory.packages.props') + { + $added = $labelsToAdd.Add("dependencies") + } + } + + foreach ($labelOnPullRequest in $labelsOnPullRequest) + { + if ($labelsToAdd.Contains($labelOnPullRequest.name)) + { + $removed = $labelsToAdd.Remove($labelOnPullRequest.name) + } + elseif ($labelOnPullRequest.name.StartsWith($labelPackagePrefix) -or + $managedLabels.Contains($labelOnPullRequest.name)) + { + $added = $labelsToRemove.Add($labelOnPullRequest.name) + } + } + + if ($labelsToAdd.Count -gt 0) + { + foreach ($label in $labelsToAdd) + { + gh pr edit $pullRequestNumber --add-label $label + } + } + + if ($labelsToRemove.Count -gt 0) + { + foreach ($label in $labelsToRemove) + { + gh pr edit $pullRequestNumber --remove-label $label + } + } +} + +Export-ModuleMember -Function AddLabelsOnPullRequestsBasedOnFilesChanged diff --git a/opentelemetry-dotnet-contrib.sln b/opentelemetry-dotnet-contrib.sln index 2d80d5dceb..f0a4560077 100644 --- a/opentelemetry-dotnet-contrib.sln +++ b/opentelemetry-dotnet-contrib.sln @@ -361,7 +361,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Shared", "Shared", "{70CA77 EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "scripts", "scripts", "{45D29DAA-0DB9-4808-B879-1AECC37EF366}" ProjectSection(SolutionItems) = preProject - build\scripts\add-labels.ps1 = build\scripts\add-labels.ps1 + build\scripts\add-labels.psm1 = build\scripts\add-labels.psm1 build\scripts\build.psm1 = build\scripts\build.psm1 build\scripts\finalize-publicapi.ps1 = build\scripts\finalize-publicapi.ps1 build\scripts\post-release.psm1 = build\scripts\post-release.psm1 From 20d2ed0172b7317844c3ee858a6d56effc2a4860 Mon Sep 17 00:00:00 2001 From: Mikel Blanchard Date: Sun, 9 Jun 2024 22:43:44 -0700 Subject: [PATCH 04/10] Fix. --- .github/workflows/add-labels.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/add-labels.yml b/.github/workflows/add-labels.yml index af7f97abcf..a809cd7a7c 100644 --- a/.github/workflows/add-labels.yml +++ b/.github/workflows/add-labels.yml @@ -48,6 +48,6 @@ jobs: AddLabelsOnPullRequestsBasedOnFilesChanged ` -pullRequestNumber ${{ github.event.pull_request.number }} ` - -labelPackagePrefix 'pkg:' + -labelPackagePrefix 'comp:' env: GH_TOKEN: ${{ github.token }} From ac7f6530185d68b06f90c26b86404c29ead7ff36 Mon Sep 17 00:00:00 2001 From: Mikel Blanchard Date: Tue, 11 Jun 2024 10:32:09 -0700 Subject: [PATCH 05/10] Bring add-label fixes from main repo. --- .github/workflows/add-labels.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/add-labels.yml b/.github/workflows/add-labels.yml index a809cd7a7c..23137c1aa8 100644 --- a/.github/workflows/add-labels.yml +++ b/.github/workflows/add-labels.yml @@ -3,7 +3,7 @@ on: issues: types: [ opened ] - pull_request: + pull_request_target: branches: [ 'main*', 'instrumentation*', 'exporter*', 'extensions*' ] permissions: @@ -33,13 +33,15 @@ jobs: ISSUE_BODY: ${{ github.event.issue.body }} add-labels-on-pull-requests: - if: github.event_name == 'pull_request' + if: github.event_name == 'pull_request_target' runs-on: ubuntu-latest steps: - name: check out code uses: actions/checkout@v4 + with: + ref: ${{ github.event.repository.default_branch }} # Note: Do not run on the PR branch we want to execute add-labels.psm1 from main on the base repo only because pull_request_target can see secrets - name: Add labels for files changed on pull requests shell: pwsh From 75b9bcc28780e677bba36e4fecfd743193ddbc3a Mon Sep 17 00:00:00 2001 From: Mikel Blanchard Date: Tue, 11 Jun 2024 21:55:05 -0700 Subject: [PATCH 06/10] Update core version update workflow to handle OpenTelemetryCoreUnstableLatestVersion. --- build/scripts/post-release.psm1 | 90 ++++++++++++++++++++++----------- 1 file changed, 61 insertions(+), 29 deletions(-) diff --git a/build/scripts/post-release.psm1 b/build/scripts/post-release.psm1 index ab786058e5..c392afe3df 100644 --- a/build/scripts/post-release.psm1 +++ b/build/scripts/post-release.psm1 @@ -264,6 +264,7 @@ function CreateOpenTelemetryCoreLatestVersionUpdatePullRequest { [Parameter(Mandatory=$true)][string]$gitRepository, [Parameter(Mandatory=$true)][string]$tag, [Parameter()][string]$targetBranch="main", + [Parameter()][string]$lineEnding="`r", [Parameter()][string]$gitUserName, [Parameter()][string]$gitUserEmail ) @@ -275,26 +276,35 @@ function CreateOpenTelemetryCoreLatestVersionUpdatePullRequest { } $tagPrefix = $match.Groups[1].Value - if ($tagPrefix.StartsWith('core-') -eq $false) + $version = $match.Groups[2].Value + $isPrerelease = ($version.Contains('-alpha.') -or $version.Contains('-beta.') -or $version.Contains('-rc.')) + + if ($tagPrefix.StartsWith('core-') -eq $true) + { + $changelogEntry = "Updated OpenTelemetry core component version(s) to" + $propertyName = "OpenTelemetryCoreLatestVersion" + $propertyVersion = "[$version,2.0)" + if ($isPrerelease -eq $true) + { + $propertyName = "OpenTelemetryCoreLatestPrereleaseVersion" + $propertyVersion = "[$version]" + } + } + elseif if ($tagPrefix.StartsWith('coreunstable-') -eq $true) + { + $changelogEntry = "Updated OpenTelemetry core unstable component version(s) to" + $propertyName = "OpenTelemetryCoreUnstableLatestVersion" + $propertyVersion = "[$version]" + } + else { Return } $projectsAndDependenciesBefore = GetCoreDependenciesForProjects - $version = $match.Groups[2].Value - $isPrerelease = ($version.Contains('-alpha.') -or $version.Contains('-beta.') -or $version.Contains('-rc.')) - $branch="release/post-core-${version}-update" - $propertyName = "OpenTelemetryCoreLatestVersion" - $propertyVersion = "[$version,2.0)" - if ($isPrerelease -eq $true) - { - $propertyName = "OpenTelemetryCoreLatestPrereleaseVersion" - $propertyVersion = "[$version]" - } - (Get-Content build/Common.props) ` -replace "<$propertyName>.*<\/$propertyName>", "<$propertyName>$propertyVersion" | Set-Content build/Common.props @@ -369,6 +379,8 @@ Merge once packages are available on NuGet and the build passes. --head $branch ` --label release + Write-Host $createPullRequestResponse + $match = [regex]::Match($createPullRequestResponse, "\/pull\/(.*)$") if ($match.Success -eq $false) { @@ -383,18 +395,24 @@ Merge once packages are available on NuGet and the build passes. } $entry = @" -* Updated OpenTelemetry core component version(s) to ``$version``. +* $changelogEntry ``$version``. ([#$pullRequestNumber](https://github.com/$gitRepository/pull/$pullRequestNumber)) "@ $lastLineBlank = $true + $changelogFilesUpdated = 0 foreach ($projectDir in $changedProjects.Keys) { $path = Join-Path -Path $projectDir -ChildPath "CHANGELOG.md" + if ([System.IO.File]::Exists($path) -eq $false) + { + continue + } + $changelogContent = Get-Content -Path $path $started = $false @@ -411,16 +429,21 @@ $entry = @" { if ($lastLineBlank -eq $false) { - $content += "`r`n" + $content += $lineEnding } $content += $entry $started = $false $isRemoving = $false } - elseif ($line -like '*Update* OpenTelemetry SDK version to*' -and $started -eq $true) + elseif ($started -eq $true -and $tagPrefix.StartsWith('core-') -eq $true -and $line -like '*Update* OpenTelemetry SDK version to*') { - $isRemoving = $true - continue + $isRemoving = $true + continue + } + elseif ($started -eq $true -and $line -like "*$changelogEntry*") + { + $isRemoving = $true + continue } if ($line.StartsWith('* ')) @@ -432,7 +455,7 @@ $entry = @" if ($lastLineBlank -eq $false) { - $content += "`r`n" + $content += $lineEnding } } @@ -441,7 +464,7 @@ $entry = @" continue } - $content += $line + "`r`n" + $content += $line + $lineEnding $lastLineBlank = [string]::IsNullOrWhitespace($line) } @@ -451,7 +474,7 @@ $entry = @" # Note: If we never wrote the entry it means the file ended in the unreleased section if ($lastLineBlank -eq $false) { - $content += "`r`n" + $content += $lineEnding } $content += $entry } @@ -463,18 +486,23 @@ $entry = @" { throw 'git add failure' } - } - git commit -m "Update CHANGELOGs for projects using $propertyName." 2>&1 | % ToString - if ($LASTEXITCODE -gt 0) - { - throw 'git commit failure' + $changelogFilesUpdated++ } - git push -u origin $branch 2>&1 | % ToString - if ($LASTEXITCODE -gt 0) + if ($changelogFilesUpdated -gt 0) { - throw 'git push failure' + git commit -m "Update CHANGELOGs for projects using $propertyName." 2>&1 | % ToString + if ($LASTEXITCODE -gt 0) + { + throw 'git commit failure' + } + + git push -u origin $branch 2>&1 | % ToString + if ($LASTEXITCODE -gt 0) + { + throw 'git push failure' + } } } @@ -504,7 +532,11 @@ function GetCoreDependenciesForProjects { if ($packageName -eq 'OpenTelemetry' -or $packageName -eq 'OpenTelemetry.Api' -or $packageName -eq 'OpenTelemetry.Api.ProviderBuilderExtensions' -or - $packageName -eq 'OpenTelemetry.Extensions.Hosting') + $packageName -eq 'OpenTelemetry.Extensions.Hosting' -or + $packageName -eq 'OpenTelemetry.Extensions.Propagators' -or + $packageName -eq 'OpenTelemetry.Exporter.Prometheus.AspNetCore' -or + $packageName -eq 'OpenTelemetry.Exporter.Prometheus.HttpListener' -or + $packageName -eq 'OpenTelemetry.Shims.OpenTracing') { $projectDependencies[$packageName.ToString()] = $packageVersion.ToString() } From b6af2ff8a33d73743f51718adbd4f7d3e4f9af9d Mon Sep 17 00:00:00 2001 From: Mikel Blanchard Date: Tue, 11 Jun 2024 22:02:51 -0700 Subject: [PATCH 07/10] Fix. --- build/scripts/post-release.psm1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build/scripts/post-release.psm1 b/build/scripts/post-release.psm1 index c392afe3df..aeabc3ab45 100644 --- a/build/scripts/post-release.psm1 +++ b/build/scripts/post-release.psm1 @@ -290,7 +290,7 @@ function CreateOpenTelemetryCoreLatestVersionUpdatePullRequest { $propertyVersion = "[$version]" } } - elseif if ($tagPrefix.StartsWith('coreunstable-') -eq $true) + elseif ($tagPrefix.StartsWith('coreunstable-') -eq $true) { $changelogEntry = "Updated OpenTelemetry core unstable component version(s) to" $propertyName = "OpenTelemetryCoreUnstableLatestVersion" From e34b12bedd5fde6f8ca9a7ee955e70a64e9d6aac Mon Sep 17 00:00:00 2001 From: Mikel Blanchard Date: Tue, 11 Jun 2024 22:11:15 -0700 Subject: [PATCH 08/10] Fix. --- build/scripts/post-release.psm1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build/scripts/post-release.psm1 b/build/scripts/post-release.psm1 index aeabc3ab45..c482500b0d 100644 --- a/build/scripts/post-release.psm1 +++ b/build/scripts/post-release.psm1 @@ -264,7 +264,7 @@ function CreateOpenTelemetryCoreLatestVersionUpdatePullRequest { [Parameter(Mandatory=$true)][string]$gitRepository, [Parameter(Mandatory=$true)][string]$tag, [Parameter()][string]$targetBranch="main", - [Parameter()][string]$lineEnding="`r", + [Parameter()][string]$lineEnding="`n", [Parameter()][string]$gitUserName, [Parameter()][string]$gitUserEmail ) From 75e50a700f824900618d8a6eb289a3f10f4c57ae Mon Sep 17 00:00:00 2001 From: Mikel Blanchard Date: Tue, 11 Jun 2024 22:43:34 -0700 Subject: [PATCH 09/10] Tweak. --- build/scripts/post-release.psm1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build/scripts/post-release.psm1 b/build/scripts/post-release.psm1 index c482500b0d..79bc92dcd9 100644 --- a/build/scripts/post-release.psm1 +++ b/build/scripts/post-release.psm1 @@ -373,7 +373,7 @@ Merge once packages are available on NuGet and the build passes. "@ $createPullRequestResponse = gh pr create ` - --title "[release] Core release $version updates" ` + --title "[release] $tag release updates" ` --body $body ` --base $targetBranch ` --head $branch ` From 40b28a7f22f5f36926bd1b0d2cb7a15f31950934 Mon Sep 17 00:00:00 2001 From: Mikel Blanchard Date: Tue, 11 Jun 2024 22:49:30 -0700 Subject: [PATCH 10/10] Tweak. --- build/scripts/post-release.psm1 | 1 + 1 file changed, 1 insertion(+) diff --git a/build/scripts/post-release.psm1 b/build/scripts/post-release.psm1 index 79bc92dcd9..63cdd1a99a 100644 --- a/build/scripts/post-release.psm1 +++ b/build/scripts/post-release.psm1 @@ -410,6 +410,7 @@ $entry = @" if ([System.IO.File]::Exists($path) -eq $false) { + Write-Host "No CHANGELOG found in $projectDir" continue }