forked from j256/two-factor-auth
-
Notifications
You must be signed in to change notification settings - Fork 0
/
release.sh
88 lines (69 loc) · 2.03 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
#!/bin/sh
#
# Release script
#
LIBRARY="two-factor-auth"
LOCAL_DIR="$HOME/svn/local/$LIBRARY"
#############################################################
# check for not commited files:
cd $LOCAL_DIR
git status | grep 'nothing to commit'
if [ $? -ne 0 ]; then
/bin/echo "Files not checked-in"
git status
exit 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 ""
/bin/echo "------------------------------------------------------- "
/bin/echo -n "Enter release number [$release]: "
read rel
if [ "$rel" != "" ]; then
release=$rel
fi
#############################################################
# run tests
cd $LOCAL_DIR
mvn test || exit 1
#############################################################
/bin/echo ""
/bin/echo -n "Enter the GPG pass-phrase: "
read gpgpass
GPG_ARGS="-Darguments=-Dgpg.passphrase=$gpgpass -Dgpg.passphrase=$gpgpass -DgpgPhase=verify"
tmp="/tmp/release.sh.$$.t"
touch $tmp
gpg --passphrase $gpgpass -s -u D3412AC1 $tmp > /dev/null 2>&1
if [ $? -ne 0 ]; then
/bin/echo "Passphrase incorrect"
exit 1
fi
rm -f $tmp*
#############################################################
/bin/echo ""
/bin/echo "------------------------------------------------------- "
/bin/echo "Releasing version '$release'"
sleep 3
#############################################################
# 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 $GPG_ARGS -P st release:prepare || exit 1
mvn $GPG_ARGS -P st release:perform || exit 1
/bin/echo ""
/bin/echo ""
fi