This commit is contained in:
Stephan 2022-03-18 18:20:34 +01:00
parent c090c23662
commit d6b1a8d591

View File

@ -43,12 +43,7 @@ module.exports = /*async*/ ({github, context, core}) => {
console.log(`Found open milestone '${version}'.`)
// github release must exist and not be published yet
try {
const release = await restapi.repos.getReleaseByTag({
owner: context.repo.owner,
repo: context.repo.repo,
tag: tag
})
const release = await getRelease()
if (release === null) {
core.setFailed(`Could not find a GitHub release for tag '${tag}'.`)
return
@ -57,12 +52,6 @@ module.exports = /*async*/ ({github, context, core}) => {
core.setFailed(`GitHub release for tag '${tag}' is already published.`)
return
}
}
catch (error)
{
core.setFailed(`Could not find a GitHub release for tag '${tag}'.`)
return
}
console.log(`Found yet-unpublished GitHub release for tag '${tag}'.`)
// tag must not exist
@ -86,11 +75,7 @@ module.exports = /*async*/ ({github, context, core}) => {
const tag = "v" + version
console.log(`Publish GitHub release '${version}'.`)
const release = await restapi.repos.getReleaseByTag({
owner: context.repo.owner,
repo: context.repo.repo,
tag: tag
})
const release = await getRelease()
await restapi.repos.updateRelease({
owner: context.repo.owner,
@ -115,6 +100,20 @@ module.exports = /*async*/ ({github, context, core}) => {
})
}
async function getRelease() {
// note: getReleaseByTag only returns published releases
const version = context.payload.inputs.version
const tag = `v${version}`
const releases = await restapi.repos.listReleases({
owner: context.repo.owner,
repo: context.repo.repo
})
const release = firstOrDefault(releases, (x) => x.tag == tag)
return release
}
async function getMilestone() {
const version = context.payload.inputs.version