Skip to content

Commit 23df733

Browse files
committed
Run release-notes tool only when we actually pull commits into the release branch
1 parent 4ed526b commit 23df733

File tree

1 file changed

+21
-19
lines changed

1 file changed

+21
-19
lines changed

scripts/release.sh

Lines changed: 21 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -140,26 +140,28 @@ if [[ $CLIENT_VERSION != *"snapshot"* ]]; then
140140
git pull -X theirs upstream master --no-edit
141141

142142
# Collect release notes from master branch
143-
start_sha=$(git log ${remote_branch}..upstream/master | grep ^commit | tail -n1 | sed 's/commit //g')
144-
end_sha=$(git log ${remote_branch}..upstream/master | grep ^commit | head -n1 | sed 's/commit //g')
145-
output="/tmp/python-master-relnote.md"
146-
release-notes --dependencies=false --org kubernetes-client --repo python --start-sha $start_sha --end-sha $end_sha --output $output
147-
sed -i 's/(\[\#/(\[kubernetes-client\/python\#/g' $output
148-
149-
IFS_backup=$IFS
150-
IFS=$'\n'
151-
sections=($(grep "^### " $output))
152-
IFS=$IFS_backup
153-
for section in "${sections[@]}"; do
154-
# ignore section titles and empty lines; replace newline with liternal "\n"
155-
master_release_notes=$(sed -n "/$section/,/###/{/###/!p}" $output | sed -n "{/^$/!p}" | sed ':a;N;$!ba;s/\n/\\n/g')
156-
util::changelog::write_changelog v$CLIENT_VERSION "$section" "$master_release_notes"
157-
done
158-
git add .
159-
if ! git diff-index --quiet --cached HEAD; then
160-
util::changelog::update_release_api_version $CLIENT_VERSION $CLIENT_VERSION $new_k8s_api_version
143+
if [[ $(git log ${remote_branch}..upstream/master | grep ^commit) ]]; then
144+
start_sha=$(git log ${remote_branch}..upstream/master | grep ^commit | tail -n1 | sed 's/commit //g')
145+
end_sha=$(git log ${remote_branch}..upstream/master | grep ^commit | head -n1 | sed 's/commit //g')
146+
output="/tmp/python-master-relnote.md"
147+
release-notes --dependencies=false --org kubernetes-client --repo python --start-sha $start_sha --end-sha $end_sha --output $output
148+
sed -i 's/(\[\#/(\[kubernetes-client\/python\#/g' $output
149+
150+
IFS_backup=$IFS
151+
IFS=$'\n'
152+
sections=($(grep "^### " $output))
153+
IFS=$IFS_backup
154+
for section in "${sections[@]}"; do
155+
# ignore section titles and empty lines; replace newline with liternal "\n"
156+
master_release_notes=$(sed -n "/$section/,/###/{/###/!p}" $output | sed -n "{/^$/!p}" | sed ':a;N;$!ba;s/\n/\\n/g')
157+
util::changelog::write_changelog v$CLIENT_VERSION "$section" "$master_release_notes"
158+
done
161159
git add .
162-
git commit -m "update changelog with release notes from master branch"
160+
if ! git diff-index --quiet --cached HEAD; then
161+
util::changelog::update_release_api_version $CLIENT_VERSION $CLIENT_VERSION $new_k8s_api_version
162+
git add .
163+
git commit -m "update changelog with release notes from master branch"
164+
fi
163165
fi
164166
fi
165167

0 commit comments

Comments
 (0)