blob: 95e20d2d4dea5c2cbb0f328a9cea3a91d4077879 [file] [log] [blame]
#!/bin/bash
#
# Copyright 2016-present the Material Components for iOS authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# Creates a release-candidate branch, creates a release section in CHANGELOG.md, and outputs an
# email to be sent to the community to stdout.
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"; pushd $DIR >> /dev/null
MDC_ROOT="$(git rev-parse --show-toplevel | tail -n1)"; popd >> /dev/null
cd $MDC_ROOT
isHotFix=false;
while test $# -gt 0; do
case "$1" in
--hotfix)
isHotFix=true;
shift
;;
esac
done
if [ ! $(git rev-parse --verify release-candidate 2> /dev/null) ]; then
git fetch
if $isHotFix; then
BRANCH_MESSAGE="This is a hotfix... branching off origin/stable"
BRANCH=origin/stable
else
BRANCH_MESSAGE="This is a normal release... branching off origin/develop"
BRANCH=origin/develop
fi
echo ${BRANCH_MESSAGE}
git checkout -b release-candidate ${BRANCH}
git push origin release-candidate
git branch --set-upstream-to=origin/release-candidate release-candidate
else
echo "Release already cut."
echo "Consider deleting your existing release-candidate branch."
exit 1
fi
# Prepare the CHANGELOG for updates.
if ! grep "# release-candidate" CHANGELOG.md >> /dev/null; then
echo -e "# release-candidate TODO: Replace me with version number. \n" | cat - CHANGELOG.md > /tmp/out && mv /tmp/out CHANGELOG.md
fi
RELEASE_SHA=$(git merge-base --fork-point release-candidate origin/develop)
today=$(date +'%B %d, %Y')
echo
echo "If you have not already, please send the following email:"
echo
echo "To: material-components-ios-discuss@googlegroups.com"
echo "Subject: State of $today release"
echo "Body:"
echo "I am about to cut the release for $today."
echo
echo "The release is being cut at $RELEASE_SHA."
echo "View this SHA on GitHub at https://github.com/material-components/material-components-ios/commit/$RELEASE_SHA"
echo
echo "We encourage clients to test out this release before it lands. To do so, check out the"
echo "release-candidate branch like so:"
echo
echo " git fetch"
echo " git checkout origin/release-candidate"
echo