@@ -64,58 +64,83 @@ source "$SCRIPT_DIR/release/check_commit_metadata.sh" "${old_version}" "${ref}"
64
64
# Sort commits by title prefix, then by date, only return sha at the end.
65
65
mapfile -t commits < <( git log --no-merges --pretty=format:" %ct %h %s" " ${old_version} ..${ref} " | sort -k3,3 -k1,1n | cut -d' ' -f2)
66
66
67
- breaking_changelog=
68
- feat_changelog=
69
- fix_changelog=
70
- other_changelog=
67
+ # From: https://github.com/commitizen/conventional-commit-types
68
+ # NOTE(mafredri): These need to be supported in check_commit_metadata.sh as well.
69
+ declare -a section_order=(
70
+ breaking
71
+ feat
72
+ fix
73
+ docs
74
+ refactor
75
+ perf
76
+ test
77
+ build
78
+ ci
79
+ chore
80
+ revert
81
+ other
82
+ )
83
+
84
+ declare -A section_titles=(
85
+ [breaking]=' BREAKING CHANGES'
86
+ [feat]=' Features'
87
+ [fix]=' Bug Fixes'
88
+ [docs]=' Documentation'
89
+ [refactor]=' Code Refactoring'
90
+ [perf]=' Performance Improvements'
91
+ [test]=' Tests'
92
+ [build]=' Builds'
93
+ [ci]=' Continuous Integration'
94
+ [chore]=' Chores'
95
+ [revert]=' Reverts'
96
+ [other]=' Other Changes'
97
+ )
98
+
99
+ # Verify that all items in section_order exist as keys in section_titles and
100
+ # vice-versa.
101
+ for cat in " ${section_order[@]} " ; do
102
+ if [[ " ${! section_titles[*]} " != * " $cat " * ]]; then
103
+ error " BUG: category $cat does not exist in section_titles"
104
+ fi
105
+ done
106
+ for cat in " ${! section_titles[@]} " ; do
107
+ if [[ " ${section_order[*]} " != * " $cat " * ]]; then
108
+ error " BUG: Category $cat does not exist in section_order"
109
+ fi
110
+ done
71
111
72
112
for commit in " ${commits[@]} " ; do
73
113
line=" - $commit ${COMMIT_METADATA_TITLE[$commit]} \n"
74
114
75
- case " ${COMMIT_METADATA_CATEGORY[$commit]} " in
76
- breaking)
77
- breaking_changelog+=" $line "
78
- ;;
79
- feat)
80
- feat_changelog+=" $line "
81
- ;;
82
- fix)
83
- fix_changelog+=" $line "
84
- ;;
85
- * )
86
- other_changelog+=" $line "
87
- ;;
88
- esac
115
+ # Default to "other" category.
116
+ cat=other
117
+ for c in " ${! section_titles[@]} " ; do
118
+ if [[ $c == " ${COMMIT_METADATA_CATEGORY[$commit]} " ]]; then
119
+ cat=$c
120
+ break
121
+ fi
122
+ done
123
+ declare " $cat " _changelog+=" $line "
89
124
done
90
125
91
126
changelog=" $(
92
- if (( ${# breaking_changelog} > 0 )) ; then
93
- echo -e " ### BREAKING CHANGES\n"
94
- echo -e " $breaking_changelog "
95
- fi
96
- if (( ${# feat_changelog} > 0 )) ; then
97
- echo -e " ### Features\n"
98
- echo -e " $feat_changelog "
99
- fi
100
- if (( ${# fix_changelog} > 0 )) ; then
101
- echo -e " ### Bug fixes\n"
102
- echo -e " $fix_changelog "
103
- fi
104
- if (( ${# other_changelog} > 0 )) ; then
105
- echo -e " ### Other changes\n"
106
- echo -e " $other_changelog "
107
- fi
127
+ for cat in " ${section_order[@]} " ; do
128
+ changes=" $( eval " echo -e \"\$ {${cat} _changelog:-}\" " ) "
129
+ if (( ${# changes} > 0 )) ; then
130
+ echo -e " \n### ${section_titles["$cat"]} \n"
131
+ echo -e " $changes "
132
+ fi
133
+ done
108
134
) "
109
135
110
136
image_tag=" $( execrelative ./image_tag.sh --version " $new_version " ) "
111
137
112
138
echo -e " ## Changelog
113
-
114
139
$changelog
115
140
116
141
Compare: [\` ${old_version} ...${new_version} \` ](https://github.com/coder/coder/compare/${old_version} ...${new_version} )
117
142
118
- ## Container image
143
+ ## Container Image
119
144
120
145
- \` docker pull $image_tag \`
121
146
"
0 commit comments