/
build-changelog.sh
executable file
·41 lines (34 loc) · 1.03 KB
/
build-changelog.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#!/bin/bash
#
# Builds a PR-oriented changelog from the git history for the given module.
#
# Usage (from top of repo):
#
# releasing/build-changelog.sh MODULE TAG CHANGE_LOG_FILE
#
# Where TAG is in the form
#
# api/v1.2.3
# kustomize/v1.2.3
# cmd/config/v1.2.3
# ... etc.
#
set -o errexit
set -o nounset
set -o pipefail
if [[ -z "${1-}" ]] || [[ -z "${2-}" ]] || [[ -z "${3-}" ]]; then
echo "Usage: $0 <module> <fullTag> <changeLogFile>"
echo "Example: $0 kyaml kyaml/v0.13.4 changelog.txt"
exit 1
fi
module=$1
fullTag=$2
changeLogFile=$3
# Find previous tag that matches the tags module
prevTag=$(git tag -l "$module*" --sort=-version:refname --no-contains="$fullTag" | head -n 1)
commits=$(git log "$prevTag".."$fullTag" \
--pretty=format:'%h' \
--abbrev-commit --no-decorate --no-color --no-merges \
-- "$module")
commitList=$(echo "$commits" | paste -s -d'+' -)
curl -sL "https://api.github.com/search/issues?q=$commitList+repo%3Akubernetes-sigs%2Fkustomize" | jq -r '.items[] | "#\(.number): \(.title) "' > "$changeLogFile"