-
Notifications
You must be signed in to change notification settings - Fork 2
/
deploy.sh
executable file
·75 lines (64 loc) · 1.38 KB
/
deploy.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
#!/bin/bash
set -e
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
cd ${SCRIPT_DIR}
print_usage() {
echo "Usage: ./$(basename $0) [snapshot|release]"
}
if [[ $# < 1 ]]
then
print_usage
exit 1
fi
case "$1" in
snapshot)
if (! grep SNAPSHOT pom.xml > /dev/null)
then
echo "Non-SNAPSHOT release found, skipping"
exit 0
fi
;;
release)
if (grep SNAPSHOT pom.xml > /dev/null)
then
echo "You can't release a SNAPSHOT artifact!"
exit 1
fi
;;
*)
print_usage
exit 1
;;
esac
echo ">>> Setting GnuPG configuration ..."
mkdir -p ~/.gnupg
chmod 700 ~/.gnupg
cat > ~/.gnupg/gpg.conf <<EOF
no-tty
pinentry-mode loopback
EOF
echo ">>> Importing secret key ..."
gpg --batch --allow-secret-key-import --import "${GPG_SECRET_KEY}"
echo ">>> Building settings.xml ..."
cat > release-settings.xml <<EOF
<settings>
<servers>
<server>
<id>ossrh</id>
<username>${SONATYPE_USERNAME}</username>
<password>${SONATYPE_PASSWORD}</password>
</server>
</servers>
<profiles>
<profile>
<id>gpg</id>
<properties>
<gpg.passphrase>${GPG_PASSWORD}</gpg.passphrase>
</properties>
</profile>
</profiles>
</settings>
EOF
trap "rm release-settings.xml" EXIT INT KILL STOP TERM
echo ">>> Running maven ..."
./mvnw -s release-settings.xml clean deploy -P release-sign-artifacts,gpg