diff --git a/gh-action-bump-version-run.js b/gh-action-bump-version-run.js index 17560f6..17017cb 100644 --- a/gh-action-bump-version-run.js +++ b/gh-action-bump-version-run.js @@ -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() diff --git a/package.json b/package.json index e40271c..7010f41 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "gh-action-bump-version", - "version": "1.0.0", + "version": "1.0.1", "description": "", "scripts": { "test": "standard"