/
release-bugfix.sh
executable file
·105 lines (82 loc) · 3.2 KB
/
release-bugfix.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
#!/bin/bash
#
# Copyright (c) 2016 org.NLP4L
#
# 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.
#
if [ -z $1 ] || [ -z $2 ] || [ -z $3 ]; then
echo "Usage: ./release-bugfix.sh <this_branch> <this_release> <next_release>"
echo " ex) ./release-bugfix.sh 1.1 1.1.1 1.1.2"
exit 1
fi
# e.g. 1.1.1, 1.1.2
THIS_BRANCH_NUM=$1
THIS_REL_NUM=$2
NEXT_REL_NUM=$3
#echo "THIS_REL_NUM : $THIS_REL_NUM"
#echo "NEXT_REL_NUM : $NEXT_REL_NUM"
echo -n "Have you executed mvn test and has it successfully done? (y/n) "
read ANS
if [ $ANS != "y" ]; then
exit 1
fi
DATE_Y=$(date +"%Y")
DATE_M=$(date +"%m")
DATE_D=$(date +"%d")
THIS_REL_DATE="${DATE_Y}-${DATE_M}-${DATE_D}"
# make sure on the target release branch
git checkout "rel-${THIS_BRANCH_NUM}"
# set the proper release date
sed -e s/YYYY-MM-DD/$THIS_REL_DATE/ CHANGES.txt > CHANGES.txt.temp
mv CHANGES.txt.temp CHANGES.txt
# update pom.xml
# commit the modification
git add .
git commit -m "prepare rel-${THIS_REL_NUM}"
git push --set-upstream origin "rel-${THIS_BRANCH_NUM}"
# tag the commit point to rel-${THIS_REL_NUM}
git tag -a "rel-${THIS_REL_NUM}" -m "release tag for ${THIS_REL_NUM}"
git push origin "rel-${THIS_REL_NUM}"
# prepare the next bug fix release on the release branch
git checkout "rel-${THIS_BRANCH_NUM}"
sed -e "1d" CHANGES.txt > CHANGES.txt.temp
cat<<EOF> CHANGES.txt
NLP4L/solr change history
========== ${NEXT_REL_NUM} / YYYY-MM-DD ===================================
Important Notice
New Features & Improvements
Bug Fixes
API Changes
Javadoc Fixes
Project environments
Tests
Deprecated/Deleted Features
Others
EOF
cat CHANGES.txt.temp >> CHANGES.txt
rm CHANGES.txt.temp
sed -e 1,10s:\<version\>$THIS_REL_NUM\<\/version\>:\<version\>$NEXT_REL_NUM\<\/version\>: pom.xml > pom.xml.temp
mv pom.xml.temp pom.xml
sed -e s/"version := "\"$THIS_REL_NUM\"/"version := "\"$NEXT_REL_NUM\"/ build.sbt > build.sbt.temp
mv build.sbt.temp build.sbt
git add .
git commit -m "prepare the next release ${NEXT_REL_NUM}"
git push
echo -e "\\n\\n\\nThe rel-${THIS_REL_NUM} has been almost prepared. Please execute the following to finalize.\\n"
echo "1. git checkout rel-${THIS_REL_NUM}"
echo "2. build nlp4l-solr-${THIS_REL_NUM}.jar file by executing mvn package. And zip that"
echo "3. Go to https://github.com/NLP4L/solr/releases/tag/rel-${THIS_REL_NUM}"
echo "4. click [Edit tag] button and drop down the zip file to the drop down box and click [Publish release]"
echo "5. to publish the artifact to the maven repository thru Sonatype, execute (1) sbt publishSigned and then (2) sbt sonatypeRelease"
echo "6. to go back to master, git checkout master"
echo -e "\\nThe download link will be https://github.com/NLP4L/solr/releases/download/rel-${THIS_REL_NUM}/nlp4l-solr-${THIS_REL_NUM}.zip"