feat: add git sha to package json

This commit is contained in:
Mikeal Rogers 2019-05-23 18:13:42 +00:00
parent d61abceefc
commit 53a92ca2d1
3 changed files with 12 additions and 3 deletions

3
.gitignore vendored Normal file
View File

@ -0,0 +1,3 @@
node_modules
package-lock.json
.nyc_output

View File

@ -1,6 +1,4 @@
#!/usr/bin/env node
console.log(process.argv)
const fs = require('fs')
const path = require('path')
const { execSync } = require('child_process')
@ -11,12 +9,17 @@ let messages = event.commits.map(commit => commit.message)
let version = 'patch'
if (messages.map(message => message.includes('BREAKING CHANGE')).includes(true)) {
version = 'major'
version = 'major'
} else if (messages.map(message => message.toLowerCase().startsWith('feat')).includes(true)) {
version = 'minor'
}
let pkg = require(path.join(process.cwd(), 'package.json'))
pkg.gitsha = process.env.GITHUB_SHA
fs.writeFileSync(path.join(process.cwd(), 'package.json'), Buffer.from(JSON.stringify(pkg)))
let current = execSync(`npm view ${pkg.name} version`).toString()
process.stdout.write(execSync(`npm version --allow-same-version=true --git-tag-version=false ${current} `))
let newVersion = execSync(`npm version --git-tag-version=false ${version}`).toString()

View File

@ -21,5 +21,8 @@
"homepage": "https://github.com/mikeal/auto-release#readme",
"dependencies": {
"yargs": "^12.0.5"
},
"devDependencies": {
"standard": "^12.0.1"
}
}