Skip to content

Commit

Permalink
feat: add messageHeadline
Browse files Browse the repository at this point in the history
  • Loading branch information
Klemensas committed Mar 8, 2020
1 parent f38f3e2 commit 4d5bc0e
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 11 deletions.
29 changes: 21 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: Klemensas/action-autotag@stable
- uses: Klemensas/action-autotag@latest
with:
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
```
Expand All @@ -37,7 +37,7 @@ This **order** is important!
```yaml
- uses: actions/checkout@v2
- uses: Klemensas/action-autotag@stable
- uses: Klemensas/action-autotag@latest
```
> If the repository is not checked out first, the autotagger cannot find the package.json file.
Expand All @@ -47,7 +47,7 @@ This **order** is important!
The `GITHUB_TOKEN` must be passed in. Without this, it is not possible to create a new tag. Make sure the autotag action looks like the following example:

```yaml
- uses: Klemensas/action-autotag@stable
- uses: Klemensas/action-autotag@latest
with:
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
```
Expand All @@ -63,7 +63,7 @@ There are several options to customize how the tag is created.
By default, autotag will look for the `package.json` file in the project root. If the file is located in a subdirectory, this option can be used to point to the correct file.

```yaml
- uses: Klemensas/action-autotag@stable
- uses: Klemensas/action-autotag@latest
with:
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
package_root: "/path/to/subdirectory"
Expand All @@ -74,7 +74,7 @@ There are several options to customize how the tag is created.
By default, `package.json` uses [semantic versioning](https://semver.org/), such as `1.0.0`. A prefix can be used to add text before the tag name. For example, if `tag_prefix` is set to `v`, then the tag would be labeled as `v1.0.0`.

```yaml
- uses: Klemensas/action-autotag@stable
- uses: Klemensas/action-autotag@latest
with:
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
tag_prefix: "v"
Expand All @@ -85,7 +85,7 @@ There are several options to customize how the tag is created.
Text can also be applied to the end of the tag by setting `tag_suffix`. For example, if `tag_suffix` is ` (beta)`, the tag would be `1.0.0 (beta)`. Please note this example violates semantic versioning and is merely here to illustrate how to add text to the end of a tag name if you _really_ want to.

```yaml
- uses: Klemensas/action-autotag@stable
- uses: Klemensas/action-autotag@latest
with:
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
tag_suffix: " (beta)"
Expand All @@ -97,19 +97,32 @@ There are several options to customize how the tag is created.
changelog will be generated from the commits between the latest tag and the new tag (HEAD). Setting this option will override it witha custom message.

```yaml
- uses: Klemensas/action-autotag@stable
- uses: Klemensas/action-autotag@latest
with:
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
tag_message: "Custom message goes here."
```
1. `changelog_structure`

Provide a custom changelog format when not using `tag_message`.
This can interpolate strings, supported strings are `{{message}}`, `{{messageHeadline}}`, `{{author}}` and `{{sha}}`.
Defaults to `**1) {{message}}** {{author}}\n(SHA: {{sha}})\n`.

```yaml
- uses: Klemensas/action-autotag@latest
with:
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
changelog_structure: "**{{messageHeadline}}** {{author}}\n"
```


1. `version`

Explicitly set the version instead of automatically detecting from `package.json`.
Useful for non-JavaScript projects where version may be output by a previous action.

```yaml
- uses: Klemensas/action-autotag@stable
- uses: Klemensas/action-autotag@latest
with:
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
version: "${{ steps.previous_step.outputs.version }}"
Expand Down
2 changes: 1 addition & 1 deletion action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ inputs:
description: This is the annotated commit message associated with the tag. By default, a changelog will be generated from the commits between the latest tag and the new tag (HEAD). This will override that with a hard-coded message.
required: false
changelog_structure:
description: "A string denoting changelog format. Supports `{{message}}`, `{{author}}` and `{{sha}}`. Defaults to `**1) {{message}}** {{author}}\n(SHA: {{sha}})\n` Only used when tag_message is empty."
description: "A string denoting changelog format. Supports `{{message}}`, {{messageHeadline}}, `{{author}}` and `{{sha}}`. Defaults to `**1) {{message}}** {{author}}\n(SHA: {{sha}})\n` Only used when tag_message is empty."
required: false
version:
description: Explicitly set the version here instead of automatically detecting from `package.json`. Useful for non-JavaScript projects where version may be output by a previous action.
Expand Down
3 changes: 2 additions & 1 deletion lib/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,9 @@ async function run() {
.map(
commit =>
structure
.replace(/({{message}})|({{author}})|({{sha}})/g, (match, message, author, sha) => {
.replace(/({{message}})|{{messageHeadline}})|({{author}})|({{sha}})/g, (match, message, messageHeadline, author, sha) => {
if (message) return commit.commit.message
if (messageHeadline) return commit.commit.messageHeadline
if (author) return !commit.hasOwnProperty('author') || !commit.author.hasOwnProperty('login') ? '' : commit.author.login
if (sha) return commit.sha
})
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "autotag-action",
"version": "1.1.0",
"version": "1.2.0",
"private": true,
"description": "Automatically create a tag whenever the version changes in package.json",
"main": "lib/main.js",
Expand Down

0 comments on commit 4d5bc0e

Please sign in to comment.