fixed script
This commit is contained in:
parent
f42da66e6c
commit
814f393bb9
|
@ -1,33 +1,21 @@
|
||||||
on: push
|
name: "Bump Version"
|
||||||
name: Build and Publish
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- "master"
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
shellLint:
|
bump-version:
|
||||||
name: Shell Lint
|
name: "Bump Version on master"
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@master
|
- name: "Checkout source code"
|
||||||
- name: Shell Lint
|
- uses: actions/checkout@v1
|
||||||
uses: actions/bin/shellcheck@master
|
- with:
|
||||||
with:
|
fetch-depth: 1
|
||||||
args: entrypoint.sh
|
- name: "Bump Version"
|
||||||
- name: Build Docker
|
uses: phips28/gh-action-bump-version@master
|
||||||
uses: actions/docker/cli@master
|
env:
|
||||||
with:
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
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 }}
|
|
||||||
|
|
|
@ -3,19 +3,25 @@ const fs = require('fs')
|
||||||
const path = require('path')
|
const path = require('path')
|
||||||
const { execSync } = require('child_process')
|
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'))
|
let pkg = require(path.join(process.cwd(), 'package.json'))
|
||||||
|
|
||||||
const run = async () => {
|
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'
|
let version = 'patch'
|
||||||
// if (messages.map(message => message.includes('BREAKING CHANGE')).includes(true)) {
|
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)) {
|
} else if (messages.map(message => message.toLowerCase().startsWith('feat')).includes(true)) {
|
||||||
// version = 'minor'
|
version = 'minor'
|
||||||
// }
|
}
|
||||||
|
|
||||||
const exec = str => {
|
const exec = str => {
|
||||||
return process.stdout.write(execSync(str))
|
return process.stdout.write(execSync(str))
|
||||||
|
@ -26,7 +32,7 @@ const run = async () => {
|
||||||
console.log('current:', current, '/', 'version:', version)
|
console.log('current:', current, '/', 'version:', version)
|
||||||
let newVersion = execSync(`npm version --git-tag-version=false ${version}`).toString()
|
let newVersion = execSync(`npm version --git-tag-version=false ${version}`).toString()
|
||||||
console.log('new version:', newVersion)
|
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 push`)
|
||||||
exec(`git tag ${newVersion}`)
|
exec(`git tag ${newVersion}`)
|
||||||
exec(`git push --tags`)
|
exec(`git push --tags`)
|
||||||
|
|
Loading…
Reference in New Issue