From ba2db3ca338eaaeb9a551e810888b787a70cee55 Mon Sep 17 00:00:00 2001 From: lowlighter <22963968+lowlighter@users.noreply.github.com> Date: Thu, 29 Apr 2021 18:37:34 +0200 Subject: [PATCH] Update releaser to use prs instead of issues --- .github/release.mjs | 26 +++++++++++--------------- 1 file changed, 11 insertions(+), 15 deletions(-) diff --git a/.github/release.mjs b/.github/release.mjs index 29a973f4..d7a4b60d 100644 --- a/.github/release.mjs +++ b/.github/release.mjs @@ -25,18 +25,18 @@ throw new Error(`Could not parse version from "${process.env.GITHUB_COMMIT_MESSAGE}"`) console.log(`Version: ${version}`) -//Load related issue - const {data:{items:issues}} = await rest.search.issuesAndPullRequests({ - q:`repo:${repository.owner}/${repository.name} is:issue is:open author:${maintainer} assignee:${maintainer} Release ${version} in:title` +//Load related pr + const {data:{items:prs}} = await rest.search.issuesAndPullRequests({ + q:`repo:${repository.owner}/${repository.name} is:pr is:merged author:${maintainer} assignee:${maintainer} Release ${version} in:title` }) -//Ensure that there is exactly one issue matching - if (issues.length < 1) - throw new Error(`No matching issues found`) - if (issues.length > 1) - throw new Error(`Multiple issues found (${issues.length} matching)`) - const [patchnote] = issues - console.log(`Using issue#${patchnote.number}: ${patchnote.title}`) +//Ensure that there is exactly one pr matching + if (prs.length < 1) + throw new Error(`No matching prs found`) + if (prs.length > 1) + throw new Error(`Multiple prs found (${prs.length} matching)`) + const [patchnote] = prs + console.log(`Using pr#${patchnote.number}: ${patchnote.title}`) //Check whether release already exists try { @@ -52,9 +52,5 @@ } //Publish release - await rest.repos.createRelease({owner:repository.owner, repo:repository.name, tag_name:version, name:`Version ${version}`, body:patchnote.body}) + await rest.repos.createRelease({owner:repository.owner, repo:repository.name, tag_name:version, name:`Version ${version.replace(/^v/g, "")}`, body:patchnote.body}) console.log(`Successfully published`) - -//Close patchnote issue - await rest.issues.update({owner:repository.owner, repo:repository.name, issue_number:patchnote.number, state:"closed"}) - console.log(`Closed #${patchnote.number}`)