Skip to content

Commit 2eec606

Browse files
separate after_deploy.sh script
1 parent b519472 commit 2eec606

File tree

3 files changed

+50
-43
lines changed

3 files changed

+50
-43
lines changed

.travis.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@ deploy:
2929
tags: true
3030
jdk: oraclejdk8
3131

32+
after_deploy:
33+
- .travis/after_deploy.sh
34+
3235
notifications:
3336
slack:
3437
rooms:

.travis/after_deploy.sh

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
#!/usr/bin/env bash
2+
set -e
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+
# increment version to the next snapshot version, commit and push to repository
22+
if [ ! -z "$TRAVIS_TAG" ]
23+
then
24+
increment_version_to_next_snapshot $TRAVIS_TAG
25+
echo "on a tag -> set pom.xml <version> to next SNAPSHOT $new_snapshot"
26+
git remote add upstream [email protected]:CurrencyFair/OneSignal-Java-SDK.git
27+
git fetch --all
28+
git checkout master
29+
mvn --settings .travis/mvnsettings.xml org.codehaus.mojo:versions-maven-plugin:2.3:set -DnewVersion=$new_snapshot
30+
mvn --settings .travis/mvnsettings.xml org.codehaus.mojo:versions-maven-plugin:2.3:commit
31+
# Save some useful information
32+
REPO=`git config remote.origin.url`
33+
SSH_REPO=${REPO/https:\/\/github.com\//git@github.com:}
34+
git config user.name "Travis CI"
35+
git config user.email "[email protected]"
36+
git add pom.xml
37+
git commit -m "[Travis-CI] next snapshot version"
38+
39+
# Get the deploy key by using Travis's stored variables to decrypt deploy_key.enc
40+
openssl aes-256-cbc -K $encrypted_7a1322f4b03c_key -iv $encrypted_7a1322f4b03c_iv -in .travis/deploy_key.enc -out .travis/deploy_key -d
41+
chmod 600 .travis/deploy_key
42+
eval `ssh-agent -s`
43+
ssh-add .travis/deploy_key
44+
45+
# Now that we're all set up, we can push.
46+
git push $SSH_REPO master
47+
fi

.travis/deploy.sh

Lines changed: 0 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,6 @@
11
#!/usr/bin/env bash
22
set -e
33

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-
214
# update current version number to a TAG version if this is a tag build
225
if [ ! -z "$TRAVIS_TAG" ]
236
then
@@ -43,29 +26,3 @@ if [ ! -z "$TRAVIS" ]; then
4326
shred -v ~/.gnupg/*
4427
rm -rf ~/.gnupg
4528
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-
git checkout master
53-
mvn --settings .travis/mvnsettings.xml org.codehaus.mojo:versions-maven-plugin:2.3:set -DnewVersion=$new_snapshot
54-
mvn --settings .travis/mvnsettings.xml org.codehaus.mojo:versions-maven-plugin:2.3:commit
55-
# Save some useful information
56-
REPO=`git config remote.origin.url`
57-
SSH_REPO=${REPO/https:\/\/github.com\//git@github.com:}
58-
git config user.name "Travis CI"
59-
git config user.email "[email protected]"
60-
git add pom.xml
61-
git commit -m "[Travis-CI] next snapshot version"
62-
63-
# Get the deploy key by using Travis's stored variables to decrypt deploy_key.enc
64-
openssl aes-256-cbc -K $encrypted_7a1322f4b03c_key -iv $encrypted_7a1322f4b03c_iv -in .travis/deploy_key.enc -out .travis/deploy_key -d
65-
chmod 600 .travis/deploy_key
66-
eval `ssh-agent -s`
67-
ssh-add .travis/deploy_key
68-
69-
# Now that we're all set up, we can push.
70-
git push $SSH_REPO master
71-
fi

0 commit comments

Comments
 (0)