From 8865d303b986328d31c7e944939b0bef011a5253 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Mon, 30 Oct 2023 08:42:15 -0700 Subject: [PATCH] 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. This is unfortunately quite difficult to test, so I haven't actually tested it. I'm hoping this won't at least halt the release so we can see how it goes for the next one and fix any issues that arise. --- .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..c0cdc9fbb94a 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`);