Merge pull request #36 from Eomm/customizable-wording

feat: customizable major and minor wording to bump new versions
This commit is contained in:
Phil 2020-09-30 15:11:11 +02:00 committed by GitHub
commit 88e90b6506
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 24 additions and 5 deletions

View File

@ -14,7 +14,7 @@ Make sure you use the `actions/checkout@v2` action!
### Workflow ### Workflow
* Based on the commit messages, increment the version from the latest release. * Based on the commit messages, increment the version from the latest release.
* If the string "BREAKING CHANGE" or "major" is found anywhere in any of the commit messages or descriptions the major * If the string "BREAKING CHANGE", "major" or the Attention pattern `refactor!: drop support for Node 6` is found anywhere in any of the commit messages or descriptions the major
version will be incremented. version will be incremented.
* If a commit message begins with the string "feat" or includes "minor" then the minor version will be increased. This works * If a commit message begins with the string "feat" or includes "minor" then the minor version will be increased. This works
for most common commit metadata for feature additions: `"feat: new API"` and `"feature: new API"`. for most common commit metadata for feature additions: `"feat: new API"` and `"feature: new API"`.
@ -30,6 +30,7 @@ Make sure you use the `actions/checkout@v2` action!
with: with:
tag-prefix: '' tag-prefix: ''
``` ```
**skip-tag:** The tag is not added to the git repository (optional). Example: **skip-tag:** The tag is not added to the git repository (optional). Example:
```yaml ```yaml
- name: 'Automated Version Bump' - name: 'Automated Version Bump'
@ -37,6 +38,16 @@ Make sure you use the `actions/checkout@v2` action!
with: with:
skip-tag: 'true' skip-tag: 'true'
``` ```
**wording:** Customize the messages that trigger the version bump. It must be a string, case sensitive, coma separated (optional). Example:
```yaml
- name: 'Automated Version Bump'
uses: 'phips28/gh-action-bump-version@master'
with:
minor-wording: 'add,Adds,new'
major-wording: 'MAJOR,cut-major'
```
**PACKAGEJSON_DIR:** Param to parse the location of the desired package.json (optional). Example: **PACKAGEJSON_DIR:** Param to parse the location of the desired package.json (optional). Example:
```yaml ```yaml
- name: 'Automated Version Bump' - name: 'Automated Version Bump'

View File

@ -11,6 +11,13 @@ inputs:
description: 'Prefix that is used for the git tag' description: 'Prefix that is used for the git tag'
default: '' default: ''
required: false required: false
minor-wording:
description: 'Words list that trigger a minor version bump'
default: 'feat,minor'
required: false
major-wording:
description: 'Words list that trigger a major version bump'
default: 'BREAKING CHANGE,major'
skip-tag: skip-tag:
description: 'Avoid to add a TAG to the version update commit' description: 'Avoid to add a TAG to the version update commit'
default: 'false' default: 'false'

View File

@ -15,7 +15,7 @@ Toolkit.run(async tools => {
if (!event.commits) { if (!event.commits) {
console.log("Couldn't find any commits in this event, incrementing patch version...") console.log("Couldn't find any commits in this event, incrementing patch version...")
} }
const messages = event.commits ? event.commits.map(commit => commit.message + '\n' + commit.body) : [] const messages = event.commits ? event.commits.map(commit => commit.message + '\n' + commit.body) : []
const commitMessage = 'version bump to' const commitMessage = 'version bump to'
@ -25,11 +25,12 @@ Toolkit.run(async tools => {
return return
} }
const majorWords = process.env['INPUT_MAJOR-WORDING'].split(',')
const minorWords = process.env['INPUT_MINOR-WORDING'].split(',')
let version = 'patch' let version = 'patch'
if (messages.map(message => /^([a-zA-Z]+)(\(.+\))?(\!)\:/.test(message) || message.includes('BREAKING CHANGE') || message.includes('major')).includes(true)) { if (messages.some(message => /^([a-zA-Z]+)(\(.+\))?(\!)\:/.test(message) || majorWords.some(word => message.includes(word)))) {
version = 'major' version = 'major'
} else if (messages.map( } else if (messages.some(message => minorWords.some(word => message.includes(word)))) {
message => message.toLowerCase().startsWith('feat') || message.toLowerCase().includes('minor')).includes(true)) {
version = 'minor' version = 'minor'
} }