ci: version bump 1.0.1

This commit is contained in:
phips28 2019-10-26 19:46:53 +02:00
parent a0ace87e9b
commit ba3b603209
2 changed files with 17 additions and 14 deletions

View File

@ -3,31 +3,34 @@ const fs = require('fs')
const path = require('path')
const { execSync } = require('child_process')
const event = JSON.parse(fs.readFileSync('/github/workflow/event.json').toString())
// const event = JSON.parse(fs.readFileSync('/github/workflow/event.json').toString())
let pkg = require(path.join(process.cwd(), 'package.json'))
const run = async () => {
if (!process.env.NPM_AUTH_TOKEN) throw new Error('gh-action-bump-version requires NPM_AUTH_TOKEN')
let messages = event.commits.map(commit => commit.message + '\n' + commit.body)
// let messages = event.commits.map(commit => commit.message + '\n' + commit.body)
//
let version = 'patch'
if (messages.map(message => message.includes('BREAKING CHANGE')).includes(true)) {
version = 'major'
} else if (messages.map(message => message.toLowerCase().startsWith('feat')).includes(true)) {
version = 'minor'
// if (messages.map(message => message.includes('BREAKING CHANGE')).includes(true)) {
// version = 'major'
// } else if (messages.map(message => message.toLowerCase().startsWith('feat')).includes(true)) {
// version = 'minor'
// }
const exec = str => {
return process.stdout.write(execSync(str))
}
const exec = str => process.stdout.write(execSync(str))
let current = execSync(`npm view ${pkg.name} version`).toString()
let current = pkg.version.toString()
exec(`npm version --allow-same-version=true --git-tag-version=false ${current} `)
console.log('current:', current, '/', 'version:', version)
let newVersion = execSync(`npm version --git-tag-version=false ${version}`).toString()
console.log('new version:', newVersion)
exec(`git commit -m 'ci: version bump ${newVersion}'`)
exec(`git commit -m 'ci: version bump 1.0.1'`)
exec(`git push`)
exec(`git checkout package.json`) // cleanup
exec(`git tag ${newVersion}`)
exec(`git push gh-action-bump-version --tags`)
exec(`git push --tags`)
}
run()

View File

@ -1,6 +1,6 @@
{
"name": "gh-action-bump-version",
"version": "1.0.0",
"version": "1.0.1",
"description": "",
"scripts": {
"test": "standard"