mirror of https://github.com/hashicorp/consul
Backport of add script to generate changelog for a PR into release/1.19.x (#21723)
* backport of commitpull/21725/headfd95026739
* backport of commit24684b3ae6
* backport of commite7993e328b
* backport of commitf235582563
* backport of commit0dbf48e15b
--------- Co-authored-by: jm96441n <john.maguire@hashicorp.com>
parent
cffdc98198
commit
cc066cd596
9
Makefile
9
Makefile
|
@ -620,6 +620,14 @@ envoy-regen: ## Regenerating envoy golden files
|
||||||
@find "command/connect/envoy/testdata" -name '*.golden' -delete
|
@find "command/connect/envoy/testdata" -name '*.golden' -delete
|
||||||
@go test -tags '$(GOTAGS)' ./command/connect/envoy -update
|
@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
|
##@ Help
|
||||||
|
|
||||||
# The help target prints out all targets with their descriptions organized
|
# The help target prints out all targets with their descriptions organized
|
||||||
|
@ -635,3 +643,4 @@ envoy-regen: ## Regenerating envoy golden files
|
||||||
.PHONY: help
|
.PHONY: help
|
||||||
help: ## Display this help.
|
help: ## Display this help.
|
||||||
@awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n make \033[36m<target>\033[0m\n"} /^[a-zA-Z_0-9-]+:.*?##/ { printf " \033[36m%-15s\033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' $(MAKEFILE_LIST)
|
@awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n make \033[36m<target>\033[0m\n"} /^[a-zA-Z_0-9-]+:.*?##/ { printf " \033[36m%-15s\033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' $(MAKEFILE_LIST)
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,73 @@
|
||||||
|
#! /bin/bash
|
||||||
|
# Copyright (c) HashiCorp, Inc.
|
||||||
|
# SPDX-License-Identifier: BUSL-1.1
|
||||||
|
|
||||||
|
set -eo pipefail
|
||||||
|
|
||||||
|
pr_number=$(gh pr list -H "$(git rev-parse --abbrev-ref HEAD)" -q ".[0].number" --json "number")
|
||||||
|
|
||||||
|
# check if this changelog is referencing an enterprise change
|
||||||
|
curdir=$(pwd)
|
||||||
|
|
||||||
|
filename = ".changelog/$pr_number.txt"
|
||||||
|
if [[ ! $curdir == *"enterprise"* ]]; then
|
||||||
|
is_enterprise = "n"
|
||||||
|
read -p "Is this an enterprise PR? (y/n): " is_enterprise
|
||||||
|
|
||||||
|
if [[ $is_enterprise == "y" ]]; then
|
||||||
|
filename = ".changelog/_$pr_number.txt"
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
filename = ".changelog/_$pr_number.txt"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# create a new changelog file
|
||||||
|
touch $filename
|
||||||
|
|
||||||
|
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\`\`\`" >>"$filename"
|
||||||
|
|
||||||
|
cat .changelog/$pr_number.txt
|
Loading…
Reference in New Issue