feat: customizable major and minor wording to bump new versions
This commit is contained in:
parent
b6568cb985
commit
f965b1a839
10
README.md
10
README.md
|
@ -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,14 @@ Make sure you use the `actions/checkout@v2` action!
|
||||||
with:
|
with:
|
||||||
tag-prefix: ''
|
tag-prefix: ''
|
||||||
```
|
```
|
||||||
|
**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'
|
||||||
|
|
|
@ -11,6 +11,14 @@ 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'
|
||||||
|
required: false
|
||||||
PACKAGEJSON_DIR:
|
PACKAGEJSON_DIR:
|
||||||
description: 'Custom dir to the package'
|
description: 'Custom dir to the package'
|
||||||
default: ''
|
default: ''
|
||||||
|
|
7
index.js
7
index.js
|
@ -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'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue