Skip to content

Commit

Permalink
feat: add latest tag filter input
Browse files Browse the repository at this point in the history
  • Loading branch information
sknuelltt committed Dec 18, 2024
1 parent 9d35d64 commit 511efce
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 3 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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: `<branch>`).
Expand Down
3 changes: 3 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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: `<keyword>:<release_type>`. Example: `hotfix:patch,pre-feat:preminor`."
required: false
Expand Down
3 changes: 2 additions & 1 deletion src/action.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down Expand Up @@ -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,
Expand Down
6 changes: 4 additions & 2 deletions src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand Down

0 comments on commit 511efce

Please sign in to comment.