-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgenerate-patch-release-notes.sh
executable file
·97 lines (81 loc) · 2.37 KB
/
generate-patch-release-notes.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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
#!/bin/bash
# Usage: generate_patch_release_notes.sh
#
# Generates and creates commits for GCP CSI driver patch release notes.
#
# Required environment variables:
# CSI_RELEASE_TOKEN: Github token needed for generating release notes
#
# Prerequisites:
# - This script creates and deletes the origin/changelog branch in your git
# workspace. Make sure you are not using the branch for anything else.
#
# Instructions:
# 1. Update the versions in the $releases array
# 2. Set environment variables
# 3. Run the script
# 4. The script pushes the commits to your origin/changelog branch
# 5. Make any modifications as needed
# 6. Create a PR
#
# Caveats:
# - This script doesn't handle regenerating and updating existing branches.
# - The "--start-rev" option in the release-notes generator is inclusive, which
# causes the last commit from the last patch to show up in the release notes (if
# there was a release note). This needs to be manually modified until a solution is found.
set -e
set -x
repo="gcp-compute-persistent-disk-csi-driver"
releases=(
"1.12.5"
"1.11.7"
"1.10.12"
"1.9.14"
"1.8.18"
"1.7.19"
)
function gen_patch_relnotes() {
rm out.md || true
rm -rf /tmp/k8s-repo || true
GITHUB_TOKEN=$CSI_RELEASE_TOKEN \
release-notes --start-rev=$3 --end-rev=$2 --branch=$2 \
--org=kubernetes-sigs --repo=$1 \
--required-author="" --markdown-links --output out.md
}
script_dir="$(dirname "$(readlink -f "$0")")"
pushd "$script_dir/../CHANGELOG"
# Create branch
git fetch upstream
git checkout master
git rebase upstream/master
branch="changelog"
if [ `git rev-parse --verify "$branch" 2>/dev/null` ]; then
git branch -D "$branch"
fi
git checkout -b $branch
for version in "${releases[@]}"; do
# Parse minor and patch version
minorPatchPattern="(^[[:digit:]]+\.[[:digit:]]+)\.([[:digit:]]+)"
[[ "$version" =~ $minorPatchPattern ]]
minor="${BASH_REMATCH[1]}"
patch="${BASH_REMATCH[2]}"
echo $repo $version $minor $patch
newVer="v$minor.$patch"
prevPatch="$(($patch-1))"
prevVer="v$minor.$prevPatch"
# Generate release notes
gen_patch_relnotes $repo release-$minor $prevVer
cat > tmp.md <<EOF
# $newVer - Changelog since $prevVer
EOF
cat out.md >> tmp.md
echo >> tmp.md
echo >> tmp.md
file="CHANGELOG-$minor.md"
cat $file >> tmp.md
mv tmp.md $file
git add -u
git commit -m "Add changelog for $version"
done
git push -f origin $branch
popd