chore: add changelog automatically

main
sundowndev 2021-12-20 14:42:34 +04:00
parent 856e4de1dc
commit 76820f88a4
No known key found for this signature in database
GPG Key ID: 100CE2799D978462
3 changed files with 22 additions and 23 deletions

2
.gitignore vendored
View File

@ -31,3 +31,5 @@
### driftctl
/.driftignore
CHANGELOG.md

View File

@ -39,6 +39,11 @@ if [ "$CI" != true ]; then
FLAGS+="--snapshot "
fi
if [ "$CI" == true ] && [ "$CMD" == "release" ]; then
./scripts/changelog.sh > CHANGELOG.md
FLAGS+="--release-notes CHANGELOG.md "
fi
CMD="goreleaser ${CMD} ${FLAGS}"
echo "+ Building using goreleaser"

View File

@ -25,34 +25,26 @@ fi
# Keep IDs of merged pull requests
PRs=$(git log --pretty=oneline $BASE...$LATEST_TAG | grep 'Merge pull request #' | grep -oP '#[0-9]+' | sed 's/#//')
echo "Generating changelog for commits from $BASE to $LATEST_TAG..."
# Generating changelog for commits from $BASE to $LATEST_TAG
CHANGES=()
for pr in $PRs; do
str=$($GHCLI_BIN pr view $pr --repo $REPO -t '- {{ .title }} (#{{ .number }}) @{{ .author.login }} {{.labels}}' --json title,number,author,labels)
CHANGES+=("$str")
done
echo -e "\n## 🚀 Enhancements\n"
for change in "${CHANGES[@]}"; do
if [[ $change =~ "kind/enhancement" ]]; then
echo $change | sed "s/\[map\[$PARTITION_COLUMN.*//"
print_changes() {
local label=$1
local title=$2
if [[ "${CHANGES[@]}" =~ $label ]]; then
echo -e $title
for change in "${CHANGES[@]}"; do
if [[ $change =~ $label ]]; then
echo $change | sed "s/\[map\[$PARTITION_COLUMN.*//"
fi
done
fi
done
}
echo -e "\n## 🐛 Bug Fixes\n"
for change in "${CHANGES[@]}"; do
if [[ $change =~ "kind/bug" ]]; then
echo $change | sed "s/\[map\[$PARTITION_COLUMN.*//"
fi
done
echo -e "\n## 🔨 Maintenance\n"
for change in "${CHANGES[@]}"; do
if [[ $change =~ "kind/maintenance" ]]; then
echo $change | sed "s/\[map\[$PARTITION_COLUMN.*//"
fi
done
print_changes "kind/enhancement" "## 🚀 Enhancements"
print_changes "kind/bug" "## 🐛 Bug Fixes"
print_changes "kind/maintenance" "## 🔨 Maintenance"