Skip to content

Commit 90226e1

Browse files
committed
fix(release): populate changelog on workflow_dispatch reruns
The "What's changed" section was built solely from github.event.pull_request.body, which is only present on the pull_request merge event. On a workflow_dispatch re-run that context is empty, so the GitHub release published with an empty changelog and failed silently. Resolve RELEASE_PR_BODY robustly: fall back to the body of the most recently merged changeset-release/main PR when the pull_request context is absent. Also fail loudly in generate-github-release.mjs when a non-prerelease resolves no changelog content, so an empty changelog can no longer publish silently. Prereleases remain exempt. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_014CjQVhMqLbRo3VuLaGSLfg
1 parent 0631c83 commit 90226e1

2 files changed

Lines changed: 30 additions & 0 deletions

File tree

.github/workflows/release.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,21 @@ jobs:
143143
STEPS_GET_VERSION_OUTPUTS_IS_PRERELEASE: ${{ steps.get_version.outputs.is_prerelease }}
144144
run: |
145145
VERSION="${STEPS_GET_VERSION_OUTPUTS_PACKAGE_VERSION}"
146+
147+
# On the pull_request merge event RELEASE_PR_BODY is the merged "Version Packages"
148+
# PR body, which holds the changelog. On a workflow_dispatch re-run (the recovery
149+
# path after a failed merge-triggered run) there is no pull_request context, so it's
150+
# empty. Fall back to the body of the most recently merged changeset-release/main PR
151+
# so the "What's changed" section is still populated.
152+
if [ -z "${RELEASE_PR_BODY}" ]; then
153+
echo "RELEASE_PR_BODY is empty (workflow_dispatch re-run); fetching merged changeset-release/main PR body"
154+
RELEASE_PR_BODY="$(gh pr list --repo triggerdotdev/trigger.dev \
155+
--head changeset-release/main --state merged \
156+
--json body,mergedAt --limit 10 \
157+
-q 'sort_by(.mergedAt) | reverse | .[0].body')"
158+
fi
159+
export RELEASE_PR_BODY
160+
146161
node scripts/generate-github-release.mjs "$VERSION" > /tmp/release-body.md
147162
PRERELEASE_FLAG=""
148163
if [ "${STEPS_GET_VERSION_OUTPUTS_IS_PRERELEASE}" = "true" ]; then

scripts/generate-github-release.mjs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,21 @@ async function main() {
239239
}
240240

241241
const changesContent = extractChangesFromPrBody(prBody);
242+
243+
// Fail loudly when a stable (non-prerelease) release resolved no changelog. This
244+
// guards against publishing an empty "What's changed" section, which previously
245+
// happened silently on workflow_dispatch re-runs where RELEASE_PR_BODY was empty.
246+
// Prereleases (any version with a hyphen, e.g. 4.5.0-rc.0) are allowed to be empty.
247+
const isPrerelease = version.includes("-");
248+
if (!changesContent && !isPrerelease) {
249+
console.error(
250+
`Error: no "What's changed" content could be resolved for v${version}. ` +
251+
`RELEASE_PR_BODY was empty or contained no changelog entries. ` +
252+
`Refusing to publish a release with an empty changelog.`
253+
);
254+
process.exit(1);
255+
}
256+
242257
const contributors = getContributors(getPreviousVersion(version));
243258
const packages = getPublishedPackages();
244259

0 commit comments

Comments
 (0)