feat: add support for providing patterns to match tags (#2098)
Co-authored-by: GitHub Action <action@github.com>
This commit is contained in:
16
src/utils.ts
16
src/utils.ts
@@ -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')
|
||||
|
||||
Reference in New Issue
Block a user