commit
172d43f157
|
@ -22,6 +22,7 @@ jobs:
|
||||||
with:
|
with:
|
||||||
node-version: 12
|
node-version: 12
|
||||||
- name: "Automated Version Bump"
|
- name: "Automated Version Bump"
|
||||||
|
id: version-bump
|
||||||
uses: "phips28/gh-action-bump-version@master"
|
uses: "phips28/gh-action-bump-version@master"
|
||||||
with:
|
with:
|
||||||
tag-prefix: ''
|
tag-prefix: ''
|
||||||
|
@ -29,3 +30,7 @@ jobs:
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
- name: "cat package.json"
|
- name: "cat package.json"
|
||||||
run: cat ./package.json
|
run: cat ./package.json
|
||||||
|
- name: 'Output Step'
|
||||||
|
env:
|
||||||
|
NEW_TAG: ${{ steps.version-bump.outputs.newTag }}
|
||||||
|
run: echo "new tag $NEW_TAG"
|
||||||
|
|
|
@ -35,3 +35,6 @@ inputs:
|
||||||
description: 'Set a default version bump to use'
|
description: 'Set a default version bump to use'
|
||||||
default: 'patch'
|
default: 'patch'
|
||||||
required: false
|
required: false
|
||||||
|
outputs:
|
||||||
|
newTag:
|
||||||
|
description: 'The newly created tag'
|
||||||
|
|
29
index.js
29
index.js
|
@ -19,7 +19,7 @@ Toolkit.run(async tools => {
|
||||||
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'
|
||||||
console.log('messages:', messages);
|
console.log('messages:', messages)
|
||||||
const isVersionBump = messages.map(message => message.toLowerCase().includes(commitMessage)).includes(true)
|
const isVersionBump = messages.map(message => message.toLowerCase().includes(commitMessage)).includes(true)
|
||||||
if (isVersionBump) {
|
if (isVersionBump) {
|
||||||
tools.exit.success('No action necessary!')
|
tools.exit.success('No action necessary!')
|
||||||
|
@ -31,25 +31,25 @@ Toolkit.run(async tools => {
|
||||||
const patchWords = process.env['INPUT_PATCH-WORDING'].split(',')
|
const patchWords = process.env['INPUT_PATCH-WORDING'].split(',')
|
||||||
const preReleaseWords = process.env['INPUT_RC-WORDING'].split(',')
|
const preReleaseWords = process.env['INPUT_RC-WORDING'].split(',')
|
||||||
|
|
||||||
let version = process.env['INPUT_DEFAULT'] || 'patch'
|
let version = process.env.INPUT_DEFAULT || 'patch'
|
||||||
let foundWord = null;
|
let foundWord = null
|
||||||
|
|
||||||
if (messages.some(
|
if (messages.some(
|
||||||
message => /^([a-zA-Z]+)(\(.+\))?(\!)\:/.test(message) || majorWords.some(word => message.includes(word)))) {
|
message => /^([a-zA-Z]+)(\(.+\))?(\!)\:/.test(message) || majorWords.some(word => message.includes(word)))) {
|
||||||
version = 'major'
|
version = 'major'
|
||||||
} else if (messages.some(message => minorWords.some(word => message.includes(word)))) {
|
} else if (messages.some(message => minorWords.some(word => message.includes(word)))) {
|
||||||
version = 'minor'
|
version = 'minor'
|
||||||
} else if (messages.some(message => preReleaseWords.some(word => {
|
} else if (messages.some(message => preReleaseWords.some(word => {
|
||||||
if (message.includes(word)) {
|
if (message.includes(word)) {
|
||||||
foundWord = word;
|
foundWord = word
|
||||||
return true;
|
return true
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
))) {
|
))) {
|
||||||
const preid = foundWord.split("-")[1];
|
const preid = foundWord.split('-')[1]
|
||||||
version = `prerelease --preid=${preid}`;
|
version = `prerelease --preid=${preid}`
|
||||||
} else if (patchWords && Array.isArray(patchWords)) {
|
} else if (patchWords && Array.isArray(patchWords)) {
|
||||||
if (!messages.some(message => patchWords.some(word => message.includes(word)))) {
|
if (!messages.some(message => patchWords.some(word => message.includes(word)))) {
|
||||||
version = null
|
version = null
|
||||||
|
@ -97,6 +97,7 @@ Toolkit.run(async tools => {
|
||||||
newVersion = execSync(`npm version --git-tag-version=false ${version}`).toString().trim()
|
newVersion = execSync(`npm version --git-tag-version=false ${version}`).toString().trim()
|
||||||
newVersion = `${process.env['INPUT_TAG-PREFIX']}${newVersion}`
|
newVersion = `${process.env['INPUT_TAG-PREFIX']}${newVersion}`
|
||||||
console.log('new version:', newVersion)
|
console.log('new version:', newVersion)
|
||||||
|
console.log(`::set-output name=newTag::${newVersion}`)
|
||||||
try {
|
try {
|
||||||
// to support "actions/checkout@v1"
|
// to support "actions/checkout@v1"
|
||||||
await tools.runInWorkspace('git', ['commit', '-a', '-m', `ci: ${commitMessage} ${newVersion}`])
|
await tools.runInWorkspace('git', ['commit', '-a', '-m', `ci: ${commitMessage} ${newVersion}`])
|
||||||
|
|
Loading…
Reference in New Issue