From 9f6e81607d2b95e126562723e581c9db6cd187c7 Mon Sep 17 00:00:00 2001 From: gsadmin Date: Fri, 31 Jul 2026 20:15:24 -0400 Subject: [PATCH] Publish the merged pull request description as the release body The release body was built solely from the CHANGELOG section, which is a terse changelog entry rather than the account of what changed. Gitea's pull_request webhook payload carries the description - PullRequest.Body is a documented field on the API struct - so it is now passed to the release step as PR_BODY and leads the release when present. The CHANGELOG entry is kept behind a fold rather than dropped, so a release records both the narrative and the versioned entry. With no description the body falls back to the CHANGELOG exactly as before, and with neither it says so. Co-author and generation trailers are stripped: they belong on the commit, not on a published release page. The description supplies its own headings, so no "## Changes" wrapper is added around it; the fallback branches emit one because a bare changelog fragment needs it. Verified by lifting the run: block straight out of the workflow and executing it, so the test exercises the shipped code rather than a copy: a description plus changelog produces the folded form, description-only omits the fold, changelog-only falls back, neither produces the placeholder, and the trailers are removed while the real content survives. Both workflows still parse as YAML with the same three jobs. Co-Authored-By: Claude Opus 5 --- .gitea/workflows/publish-psgallery.yml | 42 +++++++++++++++++++++++-- .github/workflows/publish-psgallery.yml | 42 +++++++++++++++++++++++-- 2 files changed, 78 insertions(+), 6 deletions(-) diff --git a/.gitea/workflows/publish-psgallery.yml b/.gitea/workflows/publish-psgallery.yml index 39447ec..ff816c5 100644 --- a/.gitea/workflows/publish-psgallery.yml +++ b/.gitea/workflows/publish-psgallery.yml @@ -129,6 +129,7 @@ jobs: COMMIT_SHA: ${{ github.sha }} PR_NUMBER: ${{ github.event.pull_request.number }} PR_TITLE: ${{ github.event.pull_request.title }} + PR_BODY: ${{ github.event.pull_request.body }} PR_AUTHOR: ${{ github.event.pull_request.user.login }} SERVER_URL: ${{ github.server_url }} RUN_ID: ${{ github.run_id }} @@ -175,7 +176,17 @@ jobs: Write-Host " CHANGELOG section length: $($changelogSection.Length) chars" Write-Host "==> [4/8] Building release body" - $changelogText = if ($changelogSection) { $changelogSection } else { '_No CHANGELOG section found for this version._' } + + # The merged pull request description is the account written for humans, so it leads when present. + # Trailing co-author and generation trailers are dropped; they belong on the commit, not the release. + $prBody = '' + if (-not [string]::IsNullOrWhiteSpace($env:PR_BODY)) { + $prBody = ($env:PR_BODY -replace '(?m)^\s*(Co-Authored-By|Co-authored-by):.*$', '') + $prBody = ($prBody -replace '(?m)^\s*(Generated with|🤖 Generated with).*$', '') + $prBody = $prBody.Trim() + } + Write-Host " PR description length: $($prBody.Length) chars" + $sb = New-Object System.Text.StringBuilder [void]$sb.AppendLine("**PSInfisicalAPI $($env:VERSION)**") [void]$sb.AppendLine('') @@ -188,8 +199,33 @@ jobs: [void]$sb.AppendLine("| Merged PR | [#$($env:PR_NUMBER) $($env:PR_TITLE)]($prUrl) by @$($env:PR_AUTHOR) |") [void]$sb.AppendLine("| Workflow run | [$($env:RUN_ID)]($runUrl) |") [void]$sb.AppendLine('') - [void]$sb.AppendLine('## Changes') - [void]$sb.AppendLine($changelogText) + + if ($prBody) { + # The description carries its own headings, so it is emitted without a wrapper. + [void]$sb.AppendLine($prBody) + + # Folded so the release leads with the narrative but still records the changelog entry. + if ($changelogSection) { + [void]$sb.AppendLine('') + [void]$sb.AppendLine('
') + [void]$sb.AppendLine("CHANGELOG entry for $($env:VERSION)") + [void]$sb.AppendLine('') + [void]$sb.AppendLine($changelogSection) + [void]$sb.AppendLine('') + [void]$sb.AppendLine('
') + } + } + elseif ($changelogSection) { + [void]$sb.AppendLine('## Changes') + [void]$sb.AppendLine('') + [void]$sb.AppendLine($changelogSection) + } + else { + [void]$sb.AppendLine('## Changes') + [void]$sb.AppendLine('') + [void]$sb.AppendLine('_No pull request description or CHANGELOG section found for this version._') + } + [void]$sb.AppendLine('') [void]$sb.AppendLine('## Install') [void]$sb.AppendLine('```powershell') diff --git a/.github/workflows/publish-psgallery.yml b/.github/workflows/publish-psgallery.yml index 4a211ed..2ec2a5b 100644 --- a/.github/workflows/publish-psgallery.yml +++ b/.github/workflows/publish-psgallery.yml @@ -131,6 +131,7 @@ jobs: COMMIT_SHA: ${{ github.sha }} PR_NUMBER: ${{ github.event.pull_request.number }} PR_TITLE: ${{ github.event.pull_request.title }} + PR_BODY: ${{ github.event.pull_request.body }} PR_AUTHOR: ${{ github.event.pull_request.user.login }} SERVER_URL: ${{ github.server_url }} RUN_ID: ${{ github.run_id }} @@ -177,7 +178,17 @@ jobs: Write-Host " CHANGELOG section length: $($changelogSection.Length) chars" Write-Host "==> [4/8] Building release body" - $changelogText = if ($changelogSection) { $changelogSection } else { '_No CHANGELOG section found for this version._' } + + # The merged pull request description is the account written for humans, so it leads when present. + # Trailing co-author and generation trailers are dropped; they belong on the commit, not the release. + $prBody = '' + if (-not [string]::IsNullOrWhiteSpace($env:PR_BODY)) { + $prBody = ($env:PR_BODY -replace '(?m)^\s*(Co-Authored-By|Co-authored-by):.*$', '') + $prBody = ($prBody -replace '(?m)^\s*(Generated with|🤖 Generated with).*$', '') + $prBody = $prBody.Trim() + } + Write-Host " PR description length: $($prBody.Length) chars" + $sb = New-Object System.Text.StringBuilder [void]$sb.AppendLine("**PSInfisicalAPI $($env:VERSION)**") [void]$sb.AppendLine('') @@ -190,8 +201,33 @@ jobs: [void]$sb.AppendLine("| Merged PR | [#$($env:PR_NUMBER) $($env:PR_TITLE)]($prUrl) by @$($env:PR_AUTHOR) |") [void]$sb.AppendLine("| Workflow run | [$($env:RUN_ID)]($runUrl) |") [void]$sb.AppendLine('') - [void]$sb.AppendLine('## Changes') - [void]$sb.AppendLine($changelogText) + + if ($prBody) { + # The description carries its own headings, so it is emitted without a wrapper. + [void]$sb.AppendLine($prBody) + + # Folded so the release leads with the narrative but still records the changelog entry. + if ($changelogSection) { + [void]$sb.AppendLine('') + [void]$sb.AppendLine('
') + [void]$sb.AppendLine("CHANGELOG entry for $($env:VERSION)") + [void]$sb.AppendLine('') + [void]$sb.AppendLine($changelogSection) + [void]$sb.AppendLine('') + [void]$sb.AppendLine('
') + } + } + elseif ($changelogSection) { + [void]$sb.AppendLine('## Changes') + [void]$sb.AppendLine('') + [void]$sb.AppendLine($changelogSection) + } + else { + [void]$sb.AppendLine('## Changes') + [void]$sb.AppendLine('') + [void]$sb.AppendLine('_No pull request description or CHANGELOG section found for this version._') + } + [void]$sb.AppendLine('') [void]$sb.AppendLine('## Install') [void]$sb.AppendLine('```powershell')