From 1454de5c4bba4eebe7b352526bd0a20a53532ce5 Mon Sep 17 00:00:00 2001 From: Mikeal Rogers Date: Sat, 26 Jan 2019 23:22:12 +0000 Subject: [PATCH] fix: adding proper publish steps and detection --- cli.js | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/cli.js b/cli.js index 2c5804e..6945e32 100644 --- a/cli.js +++ b/cli.js @@ -1,3 +1,19 @@ #!/usr/bin/env node const fs = require('fs') -console.log(JSON.parse(fs.readFileSync('/github/workflow/event.json').toString())) +const { execSync } = require('child_process') +const event = JSON.parse(fs.readFileSync('/github/workflow/event.json').toString()) + +let messages = event.commits.map(commit => commit.message) + +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' +} + +process.stdout.write(execSync(`npm version ${version}`)) +process.stdout.write(execSync(`npm publish --access=public`)) +process.stdout.write(execSync(`git push --tags`)) + +// npm version minor && npm publish --access=public && git push --tags