feat: add support for providing patterns to match tags (#2098)

Co-authored-by: GitHub Action <action@github.com>
This commit is contained in:
Tonye Jack
2024-05-20 22:17:52 -06:00
committed by GitHub
parent 5f0139347a
commit 03c184259a
9 changed files with 277 additions and 10 deletions

View File

@@ -832,9 +832,13 @@ export const cleanShaInput = async ({
return stdout.trim()
}
export const getPreviousGitTag = async ({
cwd
cwd,
tagsPattern,
tagsIgnorePattern
}: {
cwd: string
tagsPattern: string
tagsIgnorePattern?: string
}): Promise<{tag: string; sha: string}> => {
const {stdout} = await exec.getExecOutput(
'git',
@@ -845,7 +849,15 @@ export const getPreviousGitTag = async ({
}
)
const tags = stdout.trim().split('\n')
let tags = stdout.trim().split('\n')
if (tagsPattern) {
tags = tags.filter(tag => mm.isMatch(tag, tagsPattern))
}
if (tagsIgnorePattern) {
tags = tags.filter(tag => !mm.isMatch(tag, tagsIgnorePattern))
}
if (tags.length < 2) {
core.warning('No previous tag found')