From ffce3af6792ca781e54f9543dd826a41f3074f84 Mon Sep 17 00:00:00 2001 From: Mike Penz Date: Sun, 18 Oct 2020 10:04:10 +0200 Subject: [PATCH] - add support to prefer retrieving current `toTag` from `github.context.ref` if it starts with `refs/tags/` instead of git command --- src/main.ts | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/src/main.ts b/src/main.ts index 6968453..7716c1e 100644 --- a/src/main.ts +++ b/src/main.ts @@ -48,11 +48,21 @@ async function run(): Promise { const ignorePreReleases = core.getInput('ignorePreReleases') if (!toTag) { - // if not specified try to retrieve tag from git - const gitHelper = await createCommandManager(repositoryPath) - const latestTag = await gitHelper.latestTag() - toTag = latestTag - core.debug(`toTag = '${latestTag}'`) + // if not specified try to retrieve tag from github.context.ref + if (github.context.ref.startsWith('refs/tags/')) { + toTag = github.context.ref.replace('refs/tags/', '') + core.info( + `🔖 Resolved current tag (${toTag}) from the 'github.context.ref'` + ) + } else { + // if not specified try to retrieve tag from git + const gitHelper = await createCommandManager(repositoryPath) + const latestTag = await gitHelper.latestTag() + toTag = latestTag + core.info( + `🔖 Resolved current tag (${toTag}) from 'git rev-list --tags --skip=0 --max-count=1'` + ) + } } if (!owner || !repo) {