Skip to content

Commit

Permalink
feat: Add input to set the tag name for the latest release
Browse files Browse the repository at this point in the history
  • Loading branch information
glitch452 committed Jul 23, 2024
1 parent 2ddd66d commit 7f65c9b
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 1 deletion.
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:
default: 'false'
git-tag-suffix:
description: A value append to the git tags.
latest-tag-name:
description: The tag used to track the latest commit on the release branch.
default: latest
major-types:
description: A comma-separated list of conventional commit types that trigger a major version change.
minor-types:
Expand Down
14 changes: 14 additions & 0 deletions src/core/getInputs.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,20 @@ describe(getInputs.name, () => {
});
});

describe('latestTagName', () => {
it('Should return the default "latest-tag-name" if it is not provided', () => {
lookup['latest-tag-name'] = '';
const actual = getInputs(getters).latestTagName;
expect(actual).toStrictEqual('latest');
});

it('Should return the provided "latest-tag-name"', () => {
lookup['latest-tag-name'] = '<latestTagName>';
const actual = getInputs(getters).latestTagName;
expect(actual).toStrictEqual('<latestTagName>');
});
});

describe('majorTypes', () => {
it('Should return an empty list of no major types are provided', () => {
lookup['major-types'] = '';
Expand Down
1 change: 1 addition & 0 deletions src/core/getInputs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ export function getInputs(getters: Getters = core) {
getReleaseTitleFromPr: getters.getBooleanInput('get-release-title-from-pr'),
githubToken: getters.getInput('github-token', { required: true }),
gitTagSuffix: getters.getInput('git-tag-suffix'),
latestTagName: getters.getInput('latest-tag-name') || 'latest',
majorTypes: getters.getInput('major-types').split(',').filter(Boolean),
minorTypes: (getters.getInput('minor-types') || 'feat').split(',').filter(Boolean),
releaseBranch: getters.getInput('release-branch') || 'release',
Expand Down
2 changes: 1 addition & 1 deletion src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ export async function run() {
}

/* Push the git changes */
const releaseTags = ['latest', newTag, newTagMinor, newTagMajor];
const releaseTags = [inputs.latestTagName, newTag, newTagMinor, newTagMajor];
if (inputs.dryRun) {
core.info(`DRY RUN: Push the new commit to ${JSON.stringify({ remote, branch: inputs.releaseBranch })}`);
if (inputs.enableGitTagging) {
Expand Down

0 comments on commit 7f65c9b

Please sign in to comment.