1
0
This commit is contained in:
Stephan 2022-03-18 16:40:35 +01:00
parent 74f650bb33
commit cb40378ce6

View File

@ -16,6 +16,25 @@ module.exports = /*async*/ ({github, context, core}) => {
const version = context.payload.inputs.version
const tag = "v" + version
console.log(`Validate version '${version}'.`)
// git branch must exist
try {
const ref = await restapi.git.getRef({
owner: context.repo.owner,
repo: context.repo.repo,
ref: 'refs/heads/release' + version
})
if (ref == null) {
core.setFailed(`Could not find branch 'release/${version}'.`)
return
}
}
catch (error) {
core.setFailed(`Could not find branch 'release/${version}'.`)
return
}
// github release must exist and not be published yet
try {
const release = restapi.repos.getReleaseByTag({
owner: context.repo.owner,
@ -36,6 +55,8 @@ module.exports = /*async*/ ({github, context, core}) => {
core.setFailed(`Could not find a GitHub release for tag '${tag}'.`)
return
}
// tag must not exist
try {
const ref = await restapi.git.getRef({
owner: context.repo.owner,
@ -49,7 +70,7 @@ module.exports = /*async*/ ({github, context, core}) => {
// this is expected - the tag should not exist
}
console.log(`Found a yet-unpublished GitHub Release for tag '${tag}' which does not exist yet.`)
console.log(`Found branch 'release/${version}', a yet-unpublished GitHub Release for tag '${tag}' which does not exist yet.`)
}
function test() {