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
|
||||
|
||||
* 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.
|
||||
* 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"`.
|
||||
|
@ -30,6 +30,14 @@ Make sure you use the `actions/checkout@v2` action!
|
|||
with:
|
||||
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:
|
||||
```yaml
|
||||
- name: 'Automated Version Bump'
|
||||
|
|
|
@ -11,6 +11,14 @@ inputs:
|
|||
description: 'Prefix that is used for the git tag'
|
||||
default: ''
|
||||
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:
|
||||
description: 'Custom dir to the package'
|
||||
default: ''
|
||||
|
|
9
index.js
9
index.js
|
@ -15,7 +15,7 @@ Toolkit.run(async tools => {
|
|||
if (!event.commits) {
|
||||
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 commitMessage = 'version bump to'
|
||||
|
@ -25,11 +25,12 @@ Toolkit.run(async tools => {
|
|||
return
|
||||
}
|
||||
|
||||
const majorWords = process.env['INPUT_MAJOR-WORDING'].split(',')
|
||||
const minorWords = process.env['INPUT_MINOR-WORDING'].split(',')
|
||||
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'
|
||||
} else if (messages.map(
|
||||
message => message.toLowerCase().startsWith('feat') || message.toLowerCase().includes('minor')).includes(true)) {
|
||||
} else if (messages.some(message => minorWords.some(word => message.includes(word)))) {
|
||||
version = 'minor'
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue