Update releaser to use prs instead of issues

This commit is contained in:
lowlighter
2021-04-29 18:37:34 +02:00
parent 19f13ece5e
commit ba2db3ca33

26
.github/release.mjs vendored
View File

@@ -25,18 +25,18 @@
throw new Error(`Could not parse version from "${process.env.GITHUB_COMMIT_MESSAGE}"`) throw new Error(`Could not parse version from "${process.env.GITHUB_COMMIT_MESSAGE}"`)
console.log(`Version: ${version}`) console.log(`Version: ${version}`)
//Load related issue //Load related pr
const {data:{items:issues}} = await rest.search.issuesAndPullRequests({ const {data:{items:prs}} = await rest.search.issuesAndPullRequests({
q:`repo:${repository.owner}/${repository.name} is:issue is:open author:${maintainer} assignee:${maintainer} Release ${version} in:title` 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 //Ensure that there is exactly one pr matching
if (issues.length < 1) if (prs.length < 1)
throw new Error(`No matching issues found`) throw new Error(`No matching prs found`)
if (issues.length > 1) if (prs.length > 1)
throw new Error(`Multiple issues found (${issues.length} matching)`) throw new Error(`Multiple prs found (${prs.length} matching)`)
const [patchnote] = issues const [patchnote] = prs
console.log(`Using issue#${patchnote.number}: ${patchnote.title}`) console.log(`Using pr#${patchnote.number}: ${patchnote.title}`)
//Check whether release already exists //Check whether release already exists
try { try {
@@ -52,9 +52,5 @@
} }
//Publish release //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`) 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}`)