-
-
Notifications
You must be signed in to change notification settings - Fork 37
/
release.sh
130 lines (105 loc) · 3.34 KB
/
release.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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
#!/bin/sh
#
# Release script
#
LIBRARY="cloudwatch-logback-appender"
LOCAL_DIR="$HOME/svn/local/$LIBRARY"
#############################################################
# check initial stuff
bad=0
git status | head -1 | fgrep master > /dev/null 2>&1
if [ $? -ne 0 ]; then
/bin/echo "Should be on master branch."
git status | head -1
bad=1
fi
head -1 src/main/javadoc/doc-files/changelog.txt | fgrep '?' > /dev/null 2>&1
if [ $? -ne 1 ]; then
/bin/echo "No question-marks (?) can be in the ChangeLog top line."
head -1 src/main/javadoc/doc-files/changelog.txt
bad=1
fi
cd $LOCAL_DIR
git status | grep 'nothing to commit'
if [ $? -ne 0 ]; then
/bin/echo "Files not checked-in"
git status
bad=1
fi
#############################################################
# check maven settings
grep sonatype-nexus-snapshots $HOME/.m2/settings.xml > /dev/null 2>&1
if [ $? -ne 0 ]; then
/bin/echo "Can't find sonatype info in the maven settings.xml file"
exit 1
fi
#############################################################
release=$(grep version pom.xml | grep SNAPSHOT | head -1 | cut -f2 -d\> | cut -f1 -d\-)
/bin/echo ""
/bin/echo "------------------------------------------------------- "
/bin/echo -n "Enter release number [$release]: "
read rel
if [ "$rel" != "" ]; then
release=$rel
fi
#############################################################
# check docs:
cd $LOCAL_DIR
ver=$(head -1 src/main/javadoc/doc-files/changelog.txt | cut -f1 -d:)
if [ "$release" != "$ver" ]; then
/bin/echo "Change log top line version seems wrong:"
head -1 src/main/javadoc/doc-files/changelog.txt
bad=1
fi
grep -q $release README.md
if [ $? != 0 ]; then
/bin/echo "Could not find $release in README.md"
bad=1
fi
if [ -r "src/main/doc/$LIBRARY.texi" ]; then
ver=$(grep "^@set ${LIBRARY}_version" src/main/doc/$LIBRARY.texi | cut -f3 -d' ')
if [ "$release" != "$ver" ]; then
/bin/echo "$LIBRARY.texi version seems wrong:"
grep "^@set ${LIBRARY}_version" src/main/doc/$LIBRARY.texi
bad=1
fi
fi
if [ -r "src/main/javadoc/doc-files/$LIBRARY.html" ]; then
grep "Version $release" src/main/javadoc/doc-files/$LIBRARY.html > /dev/null
if [ $? -ne 0 ]; then
/bin/echo "javadoc doc-files $LIBRARY.html version seems wrong:"
grep "Version " src/main/javadoc/doc-files/$LIBRARY.html
bad=1
fi
fi
if [ $bad -ne 0 ]; then
echo "Please fix the previous error and re-run"
exit 1
fi
#############################################################
# run tests
cd $LOCAL_DIR
mvn test || exit 1
#############################################################
/bin/echo ""
/bin/echo "------------------------------------------------------- "
/bin/echo "Releasing version '$release'"
sleep 3
# remove the local and remote tag if any
tag="$LIBRARY-$release"
git tag -d $tag 2> /dev/null
git push --delete origin $tag 2> /dev/null
#############################################################
# releasing to sonatype
/bin/echo ""
/bin/echo ""
/bin/echo -n "Should we release to sonatype [y]: "
read cont
if [ "$cont" = "" -o "$cont" = "y" ]; then
cd $LOCAL_DIR
mvn -P st release:clean || exit 1
mvn -P st release:prepare || ( /bin/echo "Maybe use mvn release:rollback to rollback"; exit 1 )
mvn -P st release:perform || ( /bin/echo "Maybe use mvn release:rollback to rollback"; exit 1 )
/bin/echo ""
/bin/echo ""
fi