HBASE-24062 Add 2.1.10 to download page (#1454)
[hbase.git] / dev-support / create-release / release-tag.sh
blob28ade2c0915f7c16695113734a497d531f4f8f2b
1 #!/usr/bin/env bash
4 # Licensed to the Apache Software Foundation (ASF) under one or more
5 # contributor license agreements. See the NOTICE file distributed with
6 # this work for additional information regarding copyright ownership.
7 # The ASF licenses this file to You under the Apache License, Version 2.0
8 # (the "License"); you may not use this file except in compliance with
9 # the License. You may obtain a copy of the License at
11 # http://www.apache.org/licenses/LICENSE-2.0
13 # Unless required by applicable law or agreed to in writing, software
14 # distributed under the License is distributed on an "AS IS" BASIS,
15 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 # See the License for the specific language governing permissions and
17 # limitations under the License.
20 # Tags release. Updates releasenotes and changes.
21 SELF=$(cd $(dirname $0) && pwd)
22 . "$SELF/release-util.sh"
24 function exit_with_usage {
25 local NAME=$(basename $0)
26 cat << EOF
27 usage: $NAME
28 Tags an $PROJECT release on a particular branch.
30 Inputs are specified with the following environment variables:
31 ASF_USERNAME - Apache Username
32 ASF_PASSWORD - Apache Password
33 GIT_NAME - Name to use with git
34 GIT_EMAIL - E-mail address to use with git
35 GIT_BRANCH - Git branch on which to make release
36 RELEASE_VERSION - Version used in pom files for release
37 RELEASE_TAG - Name of release tag
38 NEXT_VERSION - Development version after release
39 EOF
40 exit 1
43 set -e
44 set -o pipefail
46 if [[ $@ == *"help"* ]]; then
47 exit_with_usage
50 if [[ -z "$ASF_PASSWORD" ]]; then
51 echo 'The environment variable ASF_PASSWORD is not set. Enter the password.'
52 echo
53 stty -echo && printf "ASF password: " && read ASF_PASSWORD && printf '\n' && stty echo
56 for env in ASF_USERNAME ASF_PASSWORD RELEASE_VERSION RELEASE_TAG NEXT_VERSION GIT_EMAIL \
57 GIT_NAME GIT_BRANCH GPG_KEY; do
58 if [ -z "${!env}" ]; then
59 echo "$env must be set to run this script"
60 exit 1
62 done
64 init_java
65 init_mvn
67 rm -rf ${PROJECT}
69 ASF_REPO="gitbox.apache.org/repos/asf/${PROJECT}.git"
70 # Ugly!
71 encoded_username=$(python -c "import urllib; print urllib.quote('''$ASF_USERNAME''')")
72 encoded_password=$(python -c "import urllib; print urllib.quote('''$ASF_PASSWORD''')")
73 git clone "https://$encoded_username:$encoded_password@$ASF_REPO" -b $GIT_BRANCH
74 # NOTE: Here we are prepending project name on version for fetching
75 # changes from the HBASE JIRA. It has issues for hbase, hbase-conectors,
76 # hbase-operator-tools, etc.
77 shopt -s nocasematch
78 if [ "${PROJECT}" != "hbase" ]; then
79 # Needs the '-' on the end.
80 prefix="${PROJECT}-"
82 shopt -u nocasematch
83 update_releasenotes `pwd`/${PROJECT} "${prefix}${RELEASE_VERSION}"
85 cd ${PROJECT}
87 git config user.name "$GIT_NAME"
88 git config user.email $GIT_EMAIL
90 # Create release version
91 $MVN versions:set -DnewVersion=$RELEASE_VERSION | grep -v "no value" # silence logs
92 git add RELEASENOTES.md CHANGES.md
94 git commit -a -m "Preparing ${PROJECT} release $RELEASE_TAG; tagging and updates to CHANGES.md and RELEASENOTES.md"
95 echo "Creating tag $RELEASE_TAG at the head of $GIT_BRANCH"
96 git tag $RELEASE_TAG
98 # Create next version
99 $MVN versions:set -DnewVersion=$NEXT_VERSION | grep -v "no value" # silence logs
101 git commit -a -m "Preparing development version $NEXT_VERSION"
103 if ! is_dry_run; then
104 # Push changes
105 git push origin $RELEASE_TAG
106 git push origin HEAD:$GIT_BRANCH
107 cd ..
108 rm -rf ${PROJECT}
109 else
110 cd ..
111 mv ${PROJECT} ${PROJECT}.tag
112 echo "Clone with version changes and tag available as ${PROJECT}.tag in the output directory."