add script to generate changelog for a PR

pull/21719/head
jm96441n 2024-09-12 11:27:46 -04:00
parent 1a62917ad1
commit fd95026739
2 changed files with 63 additions and 0 deletions

View File

@ -619,6 +619,13 @@ envoy-regen: ## Regenerating envoy golden files
@find "command/connect/envoy/testdata" -name '*.golden' -delete
@go test -tags '$(GOTAGS)' ./command/connect/envoy -update
##@ Changelog
.PHONY: gen-changelog
gen-changelog: ## Generate changelog entry for the current branch based on the currently open PR for that branch
@$(SHELL) $(CURDIR)/build-support/scripts/gen-changelog.sh
##@ Help
# The help target prints out all targets with their descriptions organized

View File

@ -0,0 +1,56 @@
#! /bin/bash
set -eo pipefail
pr_number=$(gh pr list -H "$(git rev-parse --abbrev-ref HEAD)" --json "number" | jq ".[].number")
# create a new changelog file
touch ".changelog/$pr_number.txt"
echo "Created a new changelog file for PR $pr_number."
# prompt user to pick from list of types of changlog from "breaking-change", "security", "feature", "deprecation", or "bug"
echo "Please select the type of change:"
echo "1. breaking-change"
echo "2. security"
echo "3. feature"
echo "4. deprecation"
echo "5. bug"
if [ -z "$1" ]; then
read -p "Enter your choice: " choice
else
choice=$1
fi
type=""
case $choice in
1)
type="breaking-change"
;;
2)
type="security"
;;
3)
type="feature"
;;
4)
type="deprecation"
;;
5)
type="bug"
;;
*)
echo "Invalid choice. Please select a number from 1 to 5."
exit 1
;;
esac
msg=""
read -ep $'Please enter the changelog message:\n' msg
echo -e "\`\`\`release-note:$type\n$msg\n\`\`\`" >>".changelog/$pr_number.txt"
cat .changelog/$pr_number.txt