/
publish_develop.sh
executable file
·118 lines (97 loc) · 3.94 KB
/
publish_develop.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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
#!/usr/bin/env bash
echo "Pull request: ${TRAVIS_PULL_REQUEST}; Branch: ${TRAVIS_BRANCH}"
github_url="https://${github_token}@${GH_REF}"
#!/usr/bin/env bash
function fix_git {
echo "Fixing git setup for $TRAVIS_BRANCH"
git checkout ${TRAVIS_BRANCH}
git branch -u origin/${TRAVIS_BRANCH}
git config branch.${TRAVIS_BRANCH}.remote origin
git config branch.${TRAVIS_BRANCH}.merge refs/heads/${TRAVIS_BRANCH}
}
function setup_git_credentials {
local target="build/git_credentials.asc"
touch ${target}
echo "protocol=https" >> ${target}
echo "host=$GH_REF" >> ${target}
echo "username=alexflav23" >> ${target}
echo "password=$github_token" >> ${target}
git config --global credential.helper cache
git credential-store --file ${target}
git remote set-url origin ${github_url}
}
function prepare_maven_release {
echo "Publishing new version to Maven Central"
echo "Creating GPG deploy key"
openssl aes-256-cbc -K $encrypted_759d2b7e5bb0_key -iv $encrypted_759d2b7e5bb0_iv -in build/deploy.asc.enc -out build/deploy.asc -d
echo "importing GPG key to local GBP repo"
gpg --fast-import build/deploy.asc
echo "Setting MAVEN_PUBLISH mode to true"
export MAVEN_PUBLISH="true"
export pgp_passphrase=${maven_password}
}
function publish_to_bintray {
export MAVEN_PUBLISH="false"
echo "Publishing new version to bintray"
sbt "+publish"
}
function setup_credentials {
echo "The current JDK version is ${TRAVIS_JDK_VERSION}"
echo "The current Scala version is ${TRAVIS_SCALA_VERSION}"
echo "Creating credentials file"
if [ -e "$HOME/.bintray/.credentials" ]; then
echo "Bintray credentials file already exists"
else
mkdir -p "$HOME/.bintray/"
touch "$HOME/.bintray/.credentials"
echo "realm = Bintray API Realm" >> "$HOME/.bintray/.credentials"
echo "host = api.bintray.com" >> "$HOME/.bintray/.credentials"
echo "user = $bintray_user" >> "$HOME/.bintray/.credentials"
echo "password = $bintray_password" >> "$HOME/.bintray/.credentials"
fi
if [ -e "$HOME/.bintray/.credentials" ]; then
echo "Bintray credentials file successfully created"
else
echo "Bintray credentials still not found"
fi
if [ -e "$HOME/.ivy2/.credentials" ]; then
echo "Maven credentials file already exists"
else
mkdir -p "$HOME/.ivy2/"
touch "$HOME/.ivy2/.credentials"
echo "realm = Sonatype Nexus Repository Manager" >> "$HOME/.ivy2/.credentials"
echo "host = oss.sonatype.org" >> "$HOME/.ivy2/.credentials"
echo "user = $maven_user" >> "$HOME/.ivy2/.credentials"
echo "password = $maven_password" >> "$HOME/.ivy2/.credentials"
fi
if [ -e "$HOME/.ivy2/.credentials" ]; then
echo "Maven credentials file successfully created"
else
echo "Maven credentials still not found"
fi
if [ -e "$HOME/.bintray/.credentials" ]; then
echo "Bintray credentials file successfully created"
else
echo "Bintray credentials still not found"
fi
}
if [ "$TRAVIS_PULL_REQUEST" == "false" ] && [ "$TRAVIS_BRANCH" == "develop" ];
then
if [ "${PUBLISH_ARTIFACT}" == "true" ]
then
echo "Setting git user email to ci@outworkers.com"
git config user.email "ci@outworkers.com"
echo "Setting git user name to Travis CI"
git config user.name "Travis CI"
setup_credentials
fix_git
setup_git_credentials
prepare_maven_release
sbt "release with-defaults"
else
echo "Publish arfifact: ${PUBLISH_ARTIFACT}; Only publishing version for Scala $TARGET_SCALA_VERSION and Oracle JDK 8 to prevent multiple artifacts"
fi
else
echo "Publish arfifact: ${PUBLISH_ARTIFACT}; Travis PR: ${TRAVIS_PULL_REQUEST}; Scala Version: ${TRAVIS_SCALA_VERSION}; Target version: ${TARGET_SCALA_VERSION}"
echo "This is either a pull request or the branch is not develop, deployment not necessary."
fi