From cb40378ce61a7d9d322fcf97b2f598e5fc949208 Mon Sep 17 00:00:00 2001 From: Stephan Date: Fri, 18 Mar 2022 16:40:35 +0100 Subject: [PATCH] exp --- .github/workflows/publish-release.js | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/.github/workflows/publish-release.js b/.github/workflows/publish-release.js index 689bf1e..5713afb 100644 --- a/.github/workflows/publish-release.js +++ b/.github/workflows/publish-release.js @@ -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() {