fixed script

This commit is contained in:
phips28 2019-10-26 20:01:14 +02:00
parent f42da66e6c
commit 814f393bb9
2 changed files with 33 additions and 39 deletions

View File

@ -1,33 +1,21 @@
on: push
name: Build and Publish
name: "Bump Version"
on:
push:
branches:
- "master"
jobs:
shellLint:
name: Shell Lint
bump-version:
name: "Bump Version on master"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- name: Shell Lint
uses: actions/bin/shellcheck@master
with:
args: entrypoint.sh
- name: Build Docker
uses: actions/docker/cli@master
with:
args: build -t npm .
- name: Build
uses: actions/npm@master
with:
args: install
- name: Test
uses: actions/npm@master
with:
args: test
- name: Publish Filter
uses: actions/bin/filter@master
with:
args: branch master
- name: Publish
uses: mikeal/merge-release@master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }}
- name: "Checkout source code"
- uses: actions/checkout@v1
- with:
fetch-depth: 1
- name: "Bump Version"
uses: phips28/gh-action-bump-version@master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

View File

@ -3,19 +3,25 @@ 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 () => {
// let messages = event.commits.map(commit => commit.message + '\n' + commit.body)
//
let messages = event.commits.map(commit => commit.message + '\n' + commit.body)
const commitMessage = 'version bump'
const isVersionBump = messages.map(message => message.toLowerCase().includes(commitMessage)).includes(true)
if (isVersionBump) {
return
}
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))
@ -26,7 +32,7 @@ const run = async () => {
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 -a -m 'ci: version bump ${newVersion}'`)
exec(`git commit -a -m 'ci: ${commitMessage} ${newVersion}'`)
exec(`git push`)
exec(`git tag ${newVersion}`)
exec(`git push --tags`)