Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Run release-notes tool only when we actually pull commits into the release branch #1602

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 25 additions & 20 deletions scripts/release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -140,26 +140,31 @@ if [[ $CLIENT_VERSION != *"snapshot"* ]]; then
git pull -X theirs upstream master --no-edit

# Collect release notes from master branch
start_sha=$(git log ${remote_branch}..upstream/master | grep ^commit | tail -n1 | sed 's/commit //g')
end_sha=$(git log ${remote_branch}..upstream/master | grep ^commit | head -n1 | sed 's/commit //g')
output="/tmp/python-master-relnote.md"
release-notes --dependencies=false --org kubernetes-client --repo python --start-sha $start_sha --end-sha $end_sha --output $output
sed -i 's/(\[\#/(\[kubernetes-client\/python\#/g' $output

IFS_backup=$IFS
IFS=$'\n'
sections=($(grep "^### " $output))
IFS=$IFS_backup
for section in "${sections[@]}"; do
# ignore section titles and empty lines; replace newline with liternal "\n"
master_release_notes=$(sed -n "/$section/,/###/{/###/!p}" $output | sed -n "{/^$/!p}" | sed ':a;N;$!ba;s/\n/\\n/g')
util::changelog::write_changelog v$CLIENT_VERSION "$section" "$master_release_notes"
done
git add .
if ! git diff-index --quiet --cached HEAD; then
util::changelog::update_release_api_version $CLIENT_VERSION $CLIENT_VERSION $new_k8s_api_version
git add .
git commit -m "update changelog with release notes from master branch"
if [[ $(git log ${remote_branch}..upstream/master | grep ^commit) ]]; then
start_sha=$(git log ${remote_branch}..upstream/master | grep ^commit | tail -n1 | sed 's/commit //g')
end_sha=$(git log ${remote_branch}..upstream/master | grep ^commit | head -n1 | sed 's/commit //g')
output="/tmp/python-master-relnote-$(date +%s).md"
release-notes --dependencies=false --org kubernetes-client --repo python --start-sha $start_sha --end-sha $end_sha --output $output
# Collect release notes from the output if non-empty
if [ -s $output ]; then
sed -i 's/(\[\#/(\[kubernetes-client\/python\#/g' $output

IFS_backup=$IFS
IFS=$'\n'
sections=($(grep "^### " $output))
IFS=$IFS_backup
for section in "${sections[@]}"; do
# ignore section titles and empty lines; replace newline with liternal "\n"
master_release_notes=$(sed -n "/$section/,/###/{/###/!p}" $output | sed -n "{/^$/!p}" | sed ':a;N;$!ba;s/\n/\\n/g')
util::changelog::write_changelog v$CLIENT_VERSION "$section" "$master_release_notes"
done
git add . # Allows us to check if there are any staged release note changes
if ! git diff-index --quiet --cached HEAD; then
util::changelog::update_release_api_version $CLIENT_VERSION $CLIENT_VERSION $new_k8s_api_version
git add . # Include the API version update before we commit
git commit -m "update changelog with release notes from master branch"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there is a git add . at line 161 and 164, but there is only one git commit at line 165

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, the first one allows us to check if there are any staged release note changes, the second one includes the API version update before we commit

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if ! git diff-index --quiet --cached HEAD; is not true, then there will be no git commit called. is tht correct?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. ! git diff-index --quiet --cached HEAD being false means there is nothing to commit, therefore we don't call git commit

fi
fi
fi
fi

Expand Down
32 changes: 18 additions & 14 deletions scripts/update-submodule.sh
Original file line number Diff line number Diff line change
Expand Up @@ -50,20 +50,24 @@ git submodule update --remote
# download release notes
start_sha=$(git diff | grep "^-Subproject commit " | sed 's/-Subproject commit //g')
end_sha=$(git diff | grep "^+Subproject commit " | sed 's/+Subproject commit //g')
output="/tmp/python-base-relnote.md"
output="/tmp/python-base-relnote-$(date +%s).md"
release-notes --dependencies=false --org kubernetes-client --repo python-base --start-sha $start_sha --end-sha $end_sha --output $output
sed -i 's/(\[\#/(\[kubernetes-client\/python-base\#/g' $output
if [ -s $output ]; then
sed -i 's/(\[\#/(\[kubernetes-client\/python-base\#/g' $output

# update changelog
IFS_backup=$IFS
IFS=$'\n'
sections=($(grep "^### " $output))
IFS=$IFS_backup
for section in "${sections[@]}"; do
# ignore section titles and empty lines; replace newline with liternal "\n"
release_notes=$(sed -n "/$section/,/###/{/###/!p}" $output | sed -n "{/^$/!p}" | sed ':a;N;$!ba;s/\n/\\n/g')
util::changelog::write_changelog "$TARGET_RELEASE" "$section" "$release_notes"
done
# update changelog
IFS_backup=$IFS
IFS=$'\n'
sections=($(grep "^### " $output))
IFS=$IFS_backup
for section in "${sections[@]}"; do
# ignore section titles and empty lines; replace newline with liternal "\n"
release_notes=$(sed -n "/$section/,/###/{/###/!p}" $output | sed -n "{/^$/!p}" | sed ':a;N;$!ba;s/\n/\\n/g')
util::changelog::write_changelog "$TARGET_RELEASE" "$section" "$release_notes"
done

rm -f $output
echo "Successfully updated CHANGELOG for submodule."
rm -f $output
echo "Successfully updated CHANGELOG for submodule."
else
echo "No CHANGELOG for submodule."
fi