@@ -143,24 +143,27 @@ if [[ $CLIENT_VERSION != *"snapshot"* ]]; then
143143 if [[ $( git log ${remote_branch} ..upstream/master | grep ^commit) ]]; then
144144 start_sha=$( git log ${remote_branch} ..upstream/master | grep ^commit | tail -n1 | sed ' s/commit //g' )
145145 end_sha=$( git log ${remote_branch} ..upstream/master | grep ^commit | head -n1 | sed ' s/commit //g' )
146- output=" /tmp/python-master-relnote.md"
146+ output=" /tmp/python-master-relnote- $( date +%s ) .md"
147147 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
159- git add .
160- if ! git diff-index --quiet --cached HEAD; then
161- util::changelog::update_release_api_version $CLIENT_VERSION $CLIENT_VERSION $new_k8s_api_version
148+ # Collect release notes from the output if non-empty
149+ if [ -s $output ]; then
150+ sed -i ' s/(\[\#/(\[kubernetes-client\/python\#/g' $output
151+
152+ IFS_backup=$IFS
153+ IFS=$' \n '
154+ sections=($( grep " ^### " $output ) )
155+ IFS=$IFS_backup
156+ for section in " ${sections[@]} " ; do
157+ # ignore section titles and empty lines; replace newline with liternal "\n"
158+ master_release_notes=$( sed -n " /$section /,/###/{/###/!p}" $output | sed -n " {/^$/!p}" | sed ' :a;N;$!ba;s/\n/\\n/g' )
159+ util::changelog::write_changelog v$CLIENT_VERSION " $section " " $master_release_notes "
160+ done
162161 git add .
163- git commit -m " update changelog with release notes from master branch"
162+ if ! git diff-index --quiet --cached HEAD; then
163+ util::changelog::update_release_api_version $CLIENT_VERSION $CLIENT_VERSION $new_k8s_api_version
164+ git add .
165+ git commit -m " update changelog with release notes from master branch"
166+ fi
164167 fi
165168 fi
166169fi
0 commit comments