Skip to content

Commit 032b316

Browse files
committed
chore: WIP move versioning to workflow
1 parent b83d178 commit 032b316

File tree

2 files changed

+2
-57
lines changed

2 files changed

+2
-57
lines changed

.husky/post-commit

Lines changed: 0 additions & 10 deletions
This file was deleted.

.husky/prepare-commit-msg

Lines changed: 2 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,58 +1,13 @@
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
256
commit_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
3011
fi
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-
5813
exit 0

0 commit comments

Comments
 (0)