From 4d5bc0e2e8cf1b527a7bccdc84cf9314ae86a542 Mon Sep 17 00:00:00 2001 From: Klemensas Dranseika Date: Sun, 8 Mar 2020 15:19:29 +0200 Subject: [PATCH] feat: add messageHeadline --- README.md | 29 +++++++++++++++++++++-------- action.yml | 2 +- lib/main.js | 3 ++- package.json | 2 +- 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index 15e3640b..d0c0091f 100644 --- a/README.md +++ b/README.md @@ -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 }}" ``` @@ -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. @@ -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 }}" ``` @@ -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" @@ -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" @@ -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)" @@ -97,11 +97,24 @@ 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` @@ -109,7 +122,7 @@ There are several options to customize how the tag is created. 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 }}" diff --git a/action.yml b/action.yml index f32c440a..5f2e736c 100644 --- a/action.yml +++ b/action.yml @@ -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. diff --git a/lib/main.js b/lib/main.js index afa5f717..08727e1a 100644 --- a/lib/main.js +++ b/lib/main.js @@ -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 }) diff --git a/package.json b/package.json index b802d256..89928937 100644 --- a/package.json +++ b/package.json @@ -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",