diff --git a/README.md b/README.md index 5625251f3..98147a14e 100644 --- a/README.md +++ b/README.md @@ -47,6 +47,7 @@ jobs: - **default_bump** _(optional)_ - Which type of bump to use when [none is explicitly provided](#bumping) when commiting to a release branch (default: `patch`). You can also set `false` to avoid generating a new tag when none is explicitly provided. Can be `patch, minor or major`. - **default_prerelease_bump** _(optional)_ - Which type of bump to use when [none is explicitly provided](#bumping) when commiting to a prerelease branch (default: `prerelease`). You can also set `false` to avoid generating a new tag when none is explicitly provided. Can be `prerelease, prepatch, preminor or premajor`. - **custom_tag** _(optional)_ - Custom tag name. If specified, it overrides bump settings. +- **latest_tag_filter** _(optional)_ - Latest tag filter. If specified, this list of tags found in the repo will be filtered by this substring. - **create_annotated_tag** _(optional)_ - Boolean to create an annotated rather than a lightweight one (default: `false`). - **tag_prefix** _(optional)_ - A prefix to the tag name (default: `v`). - **append_to_pre_release_tag** _(optional)_ - A suffix to the pre-release tag name (default: ``). diff --git a/action.yml b/action.yml index 7b8bb1da8..cab730dd8 100644 --- a/action.yml +++ b/action.yml @@ -36,6 +36,9 @@ inputs: custom_tag: description: "Custom tag name. If specified, it overrides bump settings." required: false + latest_tag_filter: + description: "Latest tag filter. If specified, this list of tags found in the repo will be filtered by this substring." + required: false custom_release_rules: description: "Comma separated list of release rules. Format: `:`. Example: `hotfix:patch,pre-feat:preminor`." required: false diff --git a/src/action.ts b/src/action.ts index 2a073169e..771ffc8eb 100644 --- a/src/action.ts +++ b/src/action.ts @@ -21,6 +21,7 @@ export default async function main() { | ReleaseType | 'false'; const tagPrefix = core.getInput('tag_prefix'); + const latestTagFilter = core.getInput('latest_tag_filter'); const customTag = core.getInput('custom_tag'); const releaseBranches = core.getInput('release_branches'); const preReleaseBranches = core.getInput('pre_release_branches'); @@ -73,7 +74,7 @@ export default async function main() { prefixRegex, /true/i.test(shouldFetchAllTags) ); - const latestTag = getLatestTag(validTags, prefixRegex, tagPrefix); + const latestTag = getLatestTag(validTags, prefixRegex, tagPrefix, latestTagFilter); const latestPrereleaseTag = getLatestPrereleaseTag( validTags, identifier, diff --git a/src/utils.ts b/src/utils.ts index 8952c345e..bb3928710 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -60,13 +60,15 @@ export function isPr(ref: string) { export function getLatestTag( tags: Tags, prefixRegex: RegExp, - tagPrefix: string + tagPrefix: string, + latestTagFilter: string ) { return ( tags.find( (tag) => prefixRegex.test(tag.name) && - !prerelease(tag.name.replace(prefixRegex, '')) + !prerelease(tag.name.replace(prefixRegex, '')) && + tag.name.includes(latestTagFilter) ) || { name: `${tagPrefix}0.0.0`, commit: {