|
1 | 1 | #!/usr/bin/env bash |
2 | 2 | set -e |
3 | 3 |
|
| 4 | +increment_version_to_next_snapshot () |
| 5 | +# http://stackoverflow.com/a/8659330/5226815 |
| 6 | +{ |
| 7 | + declare -a part=( ${1//\./ } ) |
| 8 | + declare new |
| 9 | + declare -i carry=1 |
| 10 | + |
| 11 | + for (( CNTR=${#part[@]}-1; CNTR>=0; CNTR-=1 )); do |
| 12 | + len=${#part[CNTR]} |
| 13 | + new=$((part[CNTR]+carry)) |
| 14 | + [ ${#new} -gt $len ] && carry=1 || carry=0 |
| 15 | + [ $CNTR -gt 0 ] && part[CNTR]=${new: -len} || part[CNTR]=${new} |
| 16 | + done |
| 17 | + new="${part[*]}" |
| 18 | + new_snapshot="${new// /.}-SNAPSHOT" |
| 19 | +} |
| 20 | + |
| 21 | +# update current version number to a TAG version if this is a tag build |
4 | 22 | if [ ! -z "$TRAVIS_TAG" ] |
5 | 23 | then |
6 | | - echo "on a tag -> set pom.xml <version> to $TRAVIS_TAG" |
| 24 | + echo "on a tag -> set pom.xml <version> to $TRAVIS_TAG for release" |
7 | 25 | mvn --settings .travis/mvnsettings.xml org.codehaus.mojo:versions-maven-plugin:2.3:set -DnewVersion=$TRAVIS_TAG |
8 | 26 | else |
9 | 27 | echo "not on a tag -> keep snapshot version in pom.xml" |
10 | 28 | fi |
11 | 29 |
|
| 30 | +# cleanup and generate gpg keys |
12 | 31 | if [ ! -z "$TRAVIS" -a -f "$HOME/.gnupg" ]; then |
13 | 32 | shred -v ~/.gnupg/* |
14 | 33 | rm -rf ~/.gnupg |
15 | 34 | fi |
16 | 35 |
|
17 | 36 | source .travis/gpg.sh |
18 | 37 |
|
| 38 | +# DEPLOY \o/ |
19 | 39 | mvn clean deploy --settings .travis/mvnsettings.xml -DskipTests=true --batch-mode --update-snapshots |
20 | 40 |
|
| 41 | +# cleanup gpg keys, just to be safe |
21 | 42 | if [ ! -z "$TRAVIS" ]; then |
22 | 43 | shred -v ~/.gnupg/* |
23 | 44 | rm -rf ~/.gnupg |
24 | 45 | fi |
| 46 | + |
| 47 | +# increment version to the next snapshot version, commit and push to repository |
| 48 | +if [ ! -z "$TRAVIS_TAG" ] |
| 49 | +then |
| 50 | + increment_version_to_next_snapshot $TRAVIS_TAG |
| 51 | + echo "on a tag -> set pom.xml <version> to next SNAPSHOT $new_snapshot" |
| 52 | + mvn --settings .travis/mvnsettings.xml org.codehaus.mojo:versions-maven-plugin:2.3:set -DnewVersion=$new_snapshot |
| 53 | + mvn --settings .travis/mvnsettings.xml org.codehaus.mojo:versions-maven-plugin:2.3:commit |
| 54 | + git config user.name "Travis CI" |
| 55 | + git config user.email "[email protected]" |
| 56 | + git remote add upstream "https://$GITHUB_API_TOKEN@github.com/CurrencyFair/OneSignal-Java-SDK.git" |
| 57 | + git fetch upstream |
| 58 | + git add pom.xml |
| 59 | + git commit -m "[Travis-CI] next snapshot version" |
| 60 | + git push --quiet upstream master > /dev/null 2>&1 |
| 61 | +fi |
0 commit comments