File tree Expand file tree Collapse file tree 2 files changed +2
-57
lines changed Expand file tree Collapse file tree 2 files changed +2
-57
lines changed Load Diff This file was deleted.
Original file line number Diff line number Diff line change 11#! /bin/bash
22
3- flag_file_path=' .version-update'
4-
5- # check if commit amend or normal commit
6- if [ -f $flag_file_path ]; then
7- rm $flag_file_path
8- exit 0
9- fi
10-
11- # types
12- parens=' (\(\w+\))?'
13- msg=' :\s.+'
14- opt_exclam=' !?'
15- exclam=' !'
16-
17- commit_types=' ^(build|chore|ci|docs|feat|fix|perf|refactor|revert|style|test)' $parens
18- minor_types=' ^(build|feat|revert)' $parens$msg
19- patch_types=' ^(chore|fix|perf|refactor)' $parens$msg
20-
21- version_match=' "version": *"[0-9.]\+"'
22- version_str=' "version": '
3+ commit_check=' ^(build|chore|ci|docs|feat|fix|perf|refactor|revert|style|test)(\(\w+\))?!?:\s.+'
234
245# read message to var
256commit_msg=$( cat $1 )
267
27- if ! [[ $commit_msg =~ $commit_types$opt_exclam$msg ]]; then
8+ if ! [[ $commit_msg =~ $commit_check ]]; then
289 echo ' Use Conventional Commits: https://conventionalcommits.org'
2910 exit 1
3011fi
3112
32- if [ $( git branch --show-current) != ' main' ]; then
33- exit 0
34- fi
35-
36- # bump version function
37- bumpVersion () {
38- touch $flag_file_path
39-
40- npm version --no-git-tag-version $1 > /dev/null
41-
42- sed -i -e " s/$version_match /$version_str $( npm pkg get version) /gi" public/manifest.json
43- }
44-
45- # version change type
46- if [[ $commit_msg =~ $commit_types$exclam$msg ]]; then
47- bumpVersion major
48- else
49- if [[ $commit_msg =~ $minor_types ]]; then
50- bumpVersion minor
51- else
52- if [[ $commit_msg =~ $patch_types ]]; then
53- bumpVersion patch
54- fi
55- fi
56- fi
57-
5813exit 0
You can’t perform that action at this time.
0 commit comments