@@ -29,42 +29,47 @@ const main = async ({ repo: fullRepo, token, dryRun, branch, force }) => {
2929 . filter ( ( [ k , v ] ) => k . startsWith ( 'RELEASE_PLEASE_' ) && v != null )
3030 . map ( ( [ k , v ] ) => [ k . replace ( 'RELEASE_PLEASE_' , '' ) , v ] )
3131
32+ const baseBranch = branch ?? github . repository . defaultBranch
33+
3234 const manifest = await RP . Manifest . fromManifest (
3335 github ,
34- branch ?? github . repository . defaultBranch ,
36+ baseBranch ,
3537 undefined ,
3638 undefined ,
3739 Object . fromEntries ( manifestOverrides )
3840 )
3941
40- let pullRequests = [ ]
41- let allReleases = [ ]
4242 if ( force ) {
43- // If we are forcing the release CI to run again, then we get
44- // the release PR from the repo and return it, which will trigger
45- // the rest of the steps in the workflow to run
46- const prNumber = await github . octokit . issues . listForRepo ( {
43+ const { data : releasePrs } = await github . octokit . pulls . list ( {
4744 owner,
4845 repo,
49- labels : 'autorelease: pending' ,
50- per_page : 1 ,
51- } ) . then ( res => res . data [ 0 ] ?. number )
52- if ( prNumber ) {
53- pullRequests = await github . octokit . pulls . get ( {
54- owner,
55- repo,
56- pull_number : prNumber ,
57- } ) . then ( res => [ {
58- ...res . data ,
59- headBranchName : res . data . head . ref ,
60- updates : [ ] ,
61- } ] )
46+ head : `release-please--branches--${ baseBranch } ` ,
47+ } )
48+
49+ if ( releasePrs . length !== 1 ) {
50+ throw new Error ( `Found ${ releasePrs . length } matching PRs, expected 1` )
6251 }
63- } else {
64- pullRequests = await ( dryRun ? manifest . buildPullRequests ( ) : manifest . createPullRequests ( ) )
65- allReleases = await ( dryRun ? manifest . buildReleases ( ) : manifest . createReleases ( ) )
52+
53+ const [ releasePr ] = releasePrs
54+ const id = process . env . GITHUB_RUN_ID
55+ ? `by https://github.com/${ owner } /${ repo } /actions/runs/${ process . env . GITHUB_RUN_ID } `
56+ : `manually starting at ${ new Date ( ) . toJSON ( ) } `
57+
58+ // XXX(hack): to get release please to recreate a pull request it needs
59+ // to have a different body string so we append a message a message that CI
60+ // is running. This will force release-please to rebase the PR but it
61+ // wont update the body again, so we only append to it.
62+ await github . octokit . pulls . update ( {
63+ owner,
64+ repo,
65+ pull_number : releasePr . number ,
66+ body : `${ releasePr . body . trim ( ) } \n- This PR is being recreated ${ id } ` ,
67+ } )
6668 }
6769
70+ const pullRequests = await ( dryRun ? manifest . buildPullRequests ( ) : manifest . createPullRequests ( ) )
71+ const allReleases = await ( dryRun ? manifest . buildReleases ( ) : manifest . createReleases ( ) )
72+
6873 // We only ever get a single pull request with our current release-please settings
6974 const rootPr = pullRequests . filter ( Boolean ) ?. [ 0 ]
7075 if ( rootPr ?. number ) {
0 commit comments