From 67f8c7c4f29aa6d1a9891bb3a44b35112347345b Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Tue, 31 Oct 2023 13:12:52 -0500 Subject: [PATCH] Attempt to automatically configure release notes (#7405) (#7424) * Attempt to automatically configure release notes This commit is an attempt to tackle #7068 by configuring the release notes in Github Releases with the handwritten release notes from `RELEASES.md`. The basic idea here is to split the markdown file on `-----` delimiters and then find the one which matches the version being released. Once one is found the `body` field of the API call to create the release is configured. * Update .github/actions/github-release/main.js --------- Co-authored-by: Andrew Brown --- .github/actions/github-release/main.js | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/.github/actions/github-release/main.js b/.github/actions/github-release/main.js index d61b24ed5ef3..bcf4f75b490a 100644 --- a/.github/actions/github-release/main.js +++ b/.github/actions/github-release/main.js @@ -91,13 +91,25 @@ async function runOnce() { } catch (e) { console.log("ERROR: ", JSON.stringify(e, null, 2)); core.info(`creating a release`); + + const releaseNotes = fs.readFileSync('RELEASES.md').toString(); + let notes = null; + const opts = { + owner, + repo, + tag_name: name, + prerelease: name === 'dev', + }; + if (name !== 'dev') { + for (let x of releaseNotes.split(/^---+$/m)) { + if (x.indexOf(name.substring(1)) == -1) + continue; + opts.body = x; + break; + } + } try { - release = await octokit.rest.repos.createRelease({ - owner, - repo, - tag_name: name, - prerelease: name === 'dev', - }); + release = await octokit.rest.repos.createRelease(opts); } catch(e) { console.log("ERROR: ", JSON.stringify(e, null, 2)); core.info(`fetching one more time`);