@@ -15,6 +15,8 @@ import { $fetch } from 'ofetch'
1515import { getGitDiff , loadChangelogConfig , parseCommits , generateMarkDown } from 'changelogen'
1616
1717const REPO = 'npmx-dev/npmx.dev'
18+ const MAX_RELEASE_BODY_LENGTH = 120_000
19+ const MAX_CONTRIBUTOR_LOOKUPS = 100
1820
1921interface Contributor {
2022 name : string
@@ -29,7 +31,9 @@ async function resolveContributors(
2931 const seenUsernames = new Set < string > ( )
3032 const token = process . env . GITHUB_TOKEN
3133
34+ let lookups = 0
3235 for ( const commit of rawCommits ) {
36+ if ( lookups >= MAX_CONTRIBUTOR_LOOKUPS ) break
3337 if (
3438 seenEmails . has ( commit . author . email ) ||
3539 commit . author . name . endsWith ( '[bot]' ) ||
@@ -38,6 +42,7 @@ async function resolveContributors(
3842 continue
3943 }
4044 seenEmails . add ( commit . author . email )
45+ lookups ++
4146
4247 try {
4348 const data = await $fetch < { author : { login : string } | null } > (
@@ -86,10 +91,22 @@ async function main() {
8691
8792 if ( contributors . length > 0 ) {
8893 const lines = contributors . map ( c => `- ${ c . name } (@${ c . username } )` ) . join ( '\n' )
89-
9094 output += `\n\n### ❤️ Contributors\n\n${ lines } `
9195 }
9296
97+ // Truncate if too long for GitHub Release body (125K limit)
98+ if ( output . length > MAX_RELEASE_BODY_LENGTH ) {
99+ const compareUrl = `https://github.com/${ REPO } /compare/${ from } ...${ to === 'HEAD' ? 'release' : to } `
100+ output =
101+ `> This release includes ${ rawCommits . length } commits. The full changelog is too large to display here.\n>\n` +
102+ `> [View full diff on GitHub](${ compareUrl } )\n`
103+
104+ if ( contributors . length > 0 ) {
105+ const lines = contributors . map ( c => `- ${ c . name } (@${ c . username } )` ) . join ( '\n' )
106+ output += `\n### ❤️ Contributors\n\n${ lines } `
107+ }
108+ }
109+
93110 console . log ( output )
94111}
95112
0 commit comments