Skip to content

Commit ca29960

Browse files
authored
ci: truncate release notes when exceeding GitHub size limit (#19730)
The stable release v1.2.881 failed because auto-generated release notes from v1.2.725 (156 nightly versions) exceeded GitHub's 125000 character limit. Split the release creation into two steps: 1. Generate notes via GitHub API and truncate if over 124000 chars 2. Create release with --notes-file instead of --generate-notes
1 parent 9a5c512 commit ca29960

1 file changed

Lines changed: 26 additions & 3 deletions

File tree

.github/workflows/release.yml

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,29 @@ jobs:
6565
script: |
6666
const script = require('./.github/scripts/bump_version.js')
6767
await script({ github, context, core })
68+
- name: Generate release notes
69+
id: notes
70+
uses: actions/github-script@v7
71+
with:
72+
script: |
73+
const tag = '${{ steps.bump.outputs.tag }}';
74+
const previous = '${{ steps.bump.outputs.previous }}';
75+
const sha = '${{ steps.bump.outputs.sha }}';
76+
const { data } = await github.rest.repos.generateReleaseNotes({
77+
owner: context.repo.owner,
78+
repo: context.repo.repo,
79+
tag_name: tag,
80+
target_commitish: sha,
81+
previous_tag_name: previous,
82+
});
83+
const MAX_LEN = 124000;
84+
let body = data.body;
85+
if (body.length > MAX_LEN) {
86+
core.warning(`Release notes too long (${body.length} chars), truncating to ${MAX_LEN}`);
87+
body = body.substring(0, MAX_LEN) + '\n\n> **Note**: changelog truncated due to GitHub size limits. See commit history for full details.';
88+
}
89+
const fs = require('fs');
90+
fs.writeFileSync('/tmp/release_notes.md', body);
6891
- name: Create release
6992
env:
7093
# we need workflow:write permission to create release if there were any workflow changes
@@ -73,13 +96,13 @@ jobs:
7396
run: |
7497
case "${{ steps.bump.outputs.type }}" in
7598
nightly)
76-
gh release create ${{ steps.bump.outputs.tag }} --target ${{ steps.bump.outputs.sha }} --generate-notes --notes-start-tag ${{ steps.bump.outputs.previous }} --prerelease --draft
99+
gh release create ${{ steps.bump.outputs.tag }} --target ${{ steps.bump.outputs.sha }} --notes-file /tmp/release_notes.md --prerelease --draft
77100
;;
78101
stable)
79-
gh release create ${{ steps.bump.outputs.tag }} --target ${{ steps.bump.outputs.sha }} --generate-notes --notes-start-tag ${{ steps.bump.outputs.previous }} --latest --draft
102+
gh release create ${{ steps.bump.outputs.tag }} --target ${{ steps.bump.outputs.sha }} --notes-file /tmp/release_notes.md --latest --draft
80103
;;
81104
patch)
82-
gh release create ${{ steps.bump.outputs.tag }} --target ${{ steps.bump.outputs.sha }} --generate-notes --notes-start-tag ${{ steps.bump.outputs.previous }} --prerelease --draft
105+
gh release create ${{ steps.bump.outputs.tag }} --target ${{ steps.bump.outputs.sha }} --notes-file /tmp/release_notes.md --prerelease --draft
83106
;;
84107
*)
85108
echo "Invalid release type: ${{ steps.bump.outputs.type }}"

0 commit comments

Comments
 (0)