forked from Pi4J/pi4j-v2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
deployToMavenCentral.sh
executable file
·73 lines (59 loc) · 1.66 KB
/
deployToMavenCentral.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
#!/bin/bash -e
# Your mvn settings.xml:
#
# <settings>
# <servers>
# <server>
# <id>oss.sonatype.org</id>
# <username>...</username>
# <password>...</password>
# </server>
# </servers>
# </settings>
#
# usage
if [ $# != 1 ] ; then
echo -e "Usage: ${0} <version>"
exit 1
fi
gpgKeyName="$(git config --get user.signingkey)"
# Confirm
releaseVersion=${1}
echo -e "INFO: Do you want to deploy version ${releaseVersion} to Maven Central, signing with ${gpgKeyName}? y/n"
read a
if [[ "${a}" != "y" && "${a}" != "Y" ]] ; then
exit 0;
fi
# Verify tag
echo -e "\nINFO: Verifying tag ${releaseVersion}\n\n"
if ! git tag --verify ${releaseVersion} ; then
echo -e "ERROR: Failed to verify tag ${releaseVersion}"
exit 1
fi
echo
echo
current_branch=$(pwb)
# Checkout tag
echo -e "\nINFO: Checking out tag ${releaseVersion}"
if ! git checkout ${releaseVersion} ; then
echo -e "ERROR: Failed to checkout tag ${releaseVersion}"
exit 1
fi
# cleanup trap
function cleanup {
if ! git checkout ${current_branch} ; then
echo "ERROR: Failed to checkout previous branch ${current_branch}"
exit 1
fi
}
trap cleanup EXIT
# Build and deploy
echo -e "\nINFO: Building and deploying to Maven Central..."
if ! mvn clean deploy -DskipTests -Pdeploy -Dgpg.keyname=${gpgKeyName} ; then
echo -e "ERROR: Failed to build and deploy to Maven Central!"
exit 1
fi
echo -e "\nINFO: Pi4j release ${releaseVersion} deployed to Maven Central."
echo -e "INFO: Remember, it can take up to 10 minutes to be available, and 2 hours for all synching."
echo -e "\nRepository is at: https://oss.sonatype.org/service/local/repositories/releases/content/com/pi4j/"
exit 0