1+ #! /bin/sh
2+
3+ # this script can generate draft changelog instead of painful writing it
4+ # run with `make changelog` then copy it!
5+
6+ version=" "
7+ gitTag=$( git describe --tag --abbrev=0)
8+ IFS=. read -r major minor patch <<< " $gitTag"
9+
10+ major=${major: 1}
11+
12+ type=$1
13+
14+ if [[ -z $type ]]; then
15+ read -r -p " Specify semver: major, minor, patch(default) " input
16+
17+ type=$input
18+ if [[ -z $input ]]; then
19+ type=" patch"
20+ fi
21+ fi
22+
23+ case $type in
24+ v* )
25+ version=$1
26+ ;;
27+ major)
28+ version=" $(( major + 1 )) .0.0"
29+ ;;
30+ minor)
31+ version=" $major .$(( minor + 1 )) .0"
32+ ;;
33+ patch)
34+ version=" $major .$minor .$(( patch+ 1 )) "
35+ esac
36+
37+ diffs=$( git diff --name-only HEAD $gitTag | grep " tencentcloud/*" )
38+
39+
40+ resource=" ^tencentcloud\/resource_tc_([a-z_]+)\.go$"
41+ data=" ^tencentcloud\/data_source_tc_([a-z_]+)\.go$"
42+ service=" ^tencentcloud\/service_([a-z_]+)\.go$"
43+ test=" ([a-z_]+)_test$"
44+
45+ items=" "
46+
47+
48+ for file in ${diffs} ; do
49+ module=" "
50+ fileType=" resource"
51+ if [[ $file =~ $resource ]]; then
52+ module=" tencentcloud_${BASH_REMATCH[1]} "
53+ elif [[ $file =~ $data ]]; then
54+ fileType=" data source"
55+ module=" tencentcloud_${BASH_REMATCH[1]} "
56+ elif [[ $file =~ $service ]]; then
57+ module=" tencentcloud_${BASH_REMATCH[1]} "
58+ fi
59+
60+ if [[ $module =~ $test ]]; then
61+ module=${BASH_REMATCH[1]}
62+ fi
63+ if [[ $module != " " ]]; then
64+ item=" * $fileType \` $module \` "
65+ if [[ ! $items =~ " $item " ]]; then
66+ items=" $items \n$item "
67+ fi
68+ fi
69+
70+ done
71+
72+ LANG=en_US
73+ dateStr=$( date +" %B %d, %Y" )
74+
75+ template="
76+ ## $version $dateStr
77+ \n
78+ \nFEATURES:
79+ \nDEPRECATED:
80+ \nENHANCEMENTS:
81+ \nBUGFIXES:
82+ \nCOMMON:
83+ \n
84+ $items
85+ \n
86+ "
87+
88+ echo $template
0 commit comments