From 53a92ca2d1ea3c55977f44d93e48e31e37d0bc69 Mon Sep 17 00:00:00 2001 From: Mikeal Rogers Date: Thu, 23 May 2019 18:13:42 +0000 Subject: [PATCH] feat: add git sha to package json --- .gitignore | 3 +++ merge-release-run.js | 9 ++++++--- package.json | 3 +++ 3 files changed, 12 insertions(+), 3 deletions(-) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..a1aa3dd --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +node_modules +package-lock.json +.nyc_output diff --git a/merge-release-run.js b/merge-release-run.js index 29496ce..02c38d4 100644 --- a/merge-release-run.js +++ b/merge-release-run.js @@ -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() diff --git a/package.json b/package.json index 5a4f991..22c1495 100644 --- a/package.json +++ b/package.json @@ -21,5 +21,8 @@ "homepage": "https://github.com/mikeal/auto-release#readme", "dependencies": { "yargs": "^12.0.5" + }, + "devDependencies": { + "standard": "^12.0.1" } }