Skip to content

Commit

Permalink
feat: add release-name-prefix input
Browse files Browse the repository at this point in the history
Signed-off-by: Ardalan Amini <[email protected]>
  • Loading branch information
ardalanamini committed Apr 30, 2023
1 parent c55ed3a commit 5df3903
Show file tree
Hide file tree
Showing 8 changed files with 60 additions and 5 deletions.
16 changes: 16 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ Automatic Changelog generator
- [Commit Types](#commit-types)
- [Default Commit Type](#default-commit-type)
- [Release Name](#release-name)
- [Release Name Prefix](#release-name-prefix)
- [Mention Authors](#mention-authors)
- [Mention New Contributors](#mention-new-contributors)
- [Include GitHub Compare Link](#include-compare-link)
Expand Down Expand Up @@ -111,6 +112,20 @@ _Default:_
${{ github.ref_name }}
```

#### `release-name-prefix`

**(Optional)**

Release name (version) prefix.

> Example: For a release name such as `@actions/github/v1.0.0` it would be `@actions/github/`

_Default:_

```yaml
""
```

#### `mention-authors`

**(Optional)**
Expand Down Expand Up @@ -255,6 +270,7 @@ Using with custom inputs:
revert: Reverts
default-commit-type: Other Changes
release-name: v1.0.0
release-name-prefix: ""
mention-authors: true
mention-new-contributors: true
include-compare-link: true
Expand Down
5 changes: 5 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,11 @@ inputs:
required: true
default: ${{ github.ref_name }}

release-name-prefix:
description: Release name (version) prefix
required: true
default: ""

mention-authors:
description: Mention the author of each commit
required: true
Expand Down
2 changes: 1 addition & 1 deletion action/index.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion action/index.js.map

Large diffs are not rendered by default.

5 changes: 4 additions & 1 deletion src/footer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import {
mentionNewContributors,
octokit,
releaseName,
releaseNamePrefix,
repository,
useGithubAutolink,
} from "./utils/index.js";
Expand Down Expand Up @@ -61,7 +62,9 @@ export async function generateFooter(previousTagName?: string): Promise<string>
}

if (includeCompareLink() && previousTagName) {
const link = useGithubAutolink() ? `${ url }/compare/${ previousTagName }...${ tagName }` : `\`[${ previousTagName }...${ tagName }](${ url }/compare/${ previousTagName }...${ tagName })\``;
let link = `${ url }/compare/${ previousTagName }...${ tagName }`;

if (!useGithubAutolink() || releaseNamePrefix()) link = `\`[${ previousTagName }...${ tagName }](${ url }/compare/${ previousTagName }...${ tagName })\``;

footer.push(`**Full Changelog**: ${ link }`);
}
Expand Down
1 change: 1 addition & 0 deletions src/utils/inputs/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ export * from "./include-pr-links.js";
export * from "./mention-authors.js";
export * from "./mention-new-contributors.js";
export * from "./release-name.js";
export * from "./release-name-prefix.js";
export * from "./semver.js";
export * from "./token.js";
export * from "./use-github-autolink.js";
30 changes: 30 additions & 0 deletions src/utils/inputs/release-name-prefix.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/*
* MIT License
*
* Copyright (c) 2023 Ardalan Amini
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
*/

import { input } from "../input.js";

export function releaseNamePrefix(): string {
return input("release-name-prefix");
}
4 changes: 2 additions & 2 deletions src/utils/parse-semver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@

import { parse, type SemVer } from "semver";
import { cache } from "./cache.js";
import { releaseName } from "./inputs/index.js";
import { releaseName, releaseNamePrefix } from "./inputs/index.js";

export function parseSemVer(version = releaseName()): SemVer | null {
return cache(`semver-${ version }`, () => parse(version, { includePrerelease: true } as never));
return cache(`semver-${ version }`, () => parse(version.replace(new RegExp(`^${ releaseNamePrefix() }`), ""), { includePrerelease: true } as never));
}

export { SemVer };

0 comments on commit 5df3903

Please sign in to comment.