exp
This commit is contained in:
parent
c090c23662
commit
d6b1a8d591
33
.github/workflows/publish-release.js
vendored
33
.github/workflows/publish-release.js
vendored
|
@ -43,12 +43,7 @@ module.exports = /*async*/ ({github, context, core}) => {
|
||||||
console.log(`Found open milestone '${version}'.`)
|
console.log(`Found open milestone '${version}'.`)
|
||||||
|
|
||||||
// github release must exist and not be published yet
|
// github release must exist and not be published yet
|
||||||
try {
|
const release = await getRelease()
|
||||||
const release = await restapi.repos.getReleaseByTag({
|
|
||||||
owner: context.repo.owner,
|
|
||||||
repo: context.repo.repo,
|
|
||||||
tag: tag
|
|
||||||
})
|
|
||||||
if (release === null) {
|
if (release === null) {
|
||||||
core.setFailed(`Could not find a GitHub release for tag '${tag}'.`)
|
core.setFailed(`Could not find a GitHub release for tag '${tag}'.`)
|
||||||
return
|
return
|
||||||
|
@ -57,12 +52,6 @@ module.exports = /*async*/ ({github, context, core}) => {
|
||||||
core.setFailed(`GitHub release for tag '${tag}' is already published.`)
|
core.setFailed(`GitHub release for tag '${tag}' is already published.`)
|
||||||
return
|
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}'.`)
|
console.log(`Found yet-unpublished GitHub release for tag '${tag}'.`)
|
||||||
|
|
||||||
// tag must not exist
|
// tag must not exist
|
||||||
|
@ -86,11 +75,7 @@ module.exports = /*async*/ ({github, context, core}) => {
|
||||||
const tag = "v" + version
|
const tag = "v" + version
|
||||||
console.log(`Publish GitHub release '${version}'.`)
|
console.log(`Publish GitHub release '${version}'.`)
|
||||||
|
|
||||||
const release = await restapi.repos.getReleaseByTag({
|
const release = await getRelease()
|
||||||
owner: context.repo.owner,
|
|
||||||
repo: context.repo.repo,
|
|
||||||
tag: tag
|
|
||||||
})
|
|
||||||
|
|
||||||
await restapi.repos.updateRelease({
|
await restapi.repos.updateRelease({
|
||||||
owner: context.repo.owner,
|
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() {
|
async function getMilestone() {
|
||||||
|
|
||||||
const version = context.payload.inputs.version
|
const version = context.payload.inputs.version
|
||||||
|
|
Loading…
Reference in New Issue
Block a user