1
0
This commit is contained in:
Stephan 2022-03-18 16:56:06 +01:00
parent ac561c87a4
commit 13a337a9b8
2 changed files with 58 additions and 8 deletions

View File

@ -34,13 +34,24 @@ module.exports = /*async*/ ({github, context, core}) => {
return
}
// github milestone must exist and be open
const milestone = getMilestone()
if (milestone == null) {
core.setFailed(`Could not find milestone '${version}'.`)
return
}
if (milestone.state != "open") {
core.setFailed(`Milestone '${version}' is already closed.`)
return
}
// github release must exist and not be published yet
try {
const release = restapi.repos.getReleaseByTag({
owner: context.repo.owner,
repo: context.repo.repo,
tag: tag
})
})
if (release === null) {
core.setFailed(`Could not find a GitHub release for tag '${tag}'.`)
return
@ -73,12 +84,50 @@ module.exports = /*async*/ ({github, context, core}) => {
console.log(`Found branch 'release/${version}', a yet-unpublished GitHub Release for tag '${tag}' which does not exist yet.`)
}
function test() {
console.log('TEST')
async function publishRelease() {
const version = context.payload.inputs.version
const tag = "v" + version
console.log(`Publish GitHub release '${version}'.`)
const release = restapi.repos.getReleaseByTag({
owner: context.repo.owner,
repo: context.repo.repo,
tag: tag
})
await restapi.repos.updateRelease({
owner: context.repo.owner,
repo: context.repo.repo,
release_id: release.id,
draft: false
})
}
async function closeMilestone() {
const version = context.payload.inputs.version
const tag = "v" + version
console.log(`Close milestone '${version}'.`)
const milestone = await getMilestone()
//...
}
async function getMilestone() {
const version = context.payload.inputs.version
const milestonesResponse = await restapi.issues.listMilestones({
owner: context.repo.owner,
repo: context.repo.repo
})
const milestones = milestonesResponse.data
return firstOrDefault(milestones, (x) => x.title == version)
}
return {
test: test,
validateRelease: validateRelease
validateRelease: validateRelease,
publishRelease: publishRelease,
closeMilestone: closeMilestone
}
}

View File

@ -28,6 +28,7 @@ jobs:
script: |
const scriptf = require('./.github/workflows/publish-release.js')
const script = scriptf({github, context, core})
console.log(script)
script.test()
await script.validateRelease()
await script.validateRelease()
// rest should be in a different step
// await script.publishRelease()
// await script.closeMilestone()