forked from graphql-java-kickstart/graphql-java-servlet
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtravis-build.sh
More file actions
76 lines (65 loc) · 2 KB
/
travis-build.sh
File metadata and controls
76 lines (65 loc) · 2 KB
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
#!/bin/bash
set -ev
saveGitCredentials() {
cat >$HOME/.netrc <<EOL
machine github.com
login ${GITHUB_USERNAME}
password ${GITHUB_TOKEN}
machine api.github.com
login ${GITHUB_USERNAME}
password ${GITHUB_TOKEN}
EOL
chmod 600 $HOME/.netrc
}
getVersion() {
./gradlew properties -q | grep "version:" | grep -v "kotlin_version:" | awk '{print $2}' | tr -d '[:space:]'
}
removeSnapshots() {
sed -i 's/-SNAPSHOT//' gradle.properties
}
commitRelease() {
local APP_VERSION=$(getVersion)
git commit -a -m "Update version for release"
git tag -a "v${APP_VERSION}" -m "Tag release version"
}
bumpVersion() {
echo "Bump version number"
local APP_VERSION=$(getVersion | xargs)
local SEMANTIC_REGEX='^([0-9]+)\.([0-9]+)(\.([0-9]+))?$'
if [[ ${APP_VERSION} =~ ${SEMANTIC_REGEX} ]]; then
if [[ ${BASH_REMATCH[4]} ]]; then
nextVersion=$((BASH_REMATCH[4] + 1))
nextVersion="${BASH_REMATCH[1]}.${BASH_REMATCH[2]}.${nextVersion}-SNAPSHOT"
else
nextVersion=$((BASH_REMATCH[2] + 1))
nextVersion="${BASH_REMATCH[1]}.${nextVersion}-SNAPSHOT"
fi
echo "Next version: ${nextVersion}"
sed -i -E "s/^version(\s)?=.*/version=${nextVersion}/" gradle.properties
else
echo "No semantic version and therefore cannot publish to maven repository: '${APP_VERSION}'"
fi
}
commitNextVersion() {
git commit -a -m "Update version for release"
}
if [ "${TRAVIS_PULL_REQUEST}" = "false" ] && [ "${TRAVIS_BRANCH}" = "master" ]; then
if [ "${RELEASE}" = "true" ]; then
echo "Deploying release to Bintray"
saveGitCredentials
git checkout -f ${TRAVIS_BRANCH}
removeSnapshots
./gradlew clean assemble && ./gradlew check --info && ./gradlew bintrayUpload -x check --info
commitRelease
bumpVersion
commitNextVersion
git push --follow-tags
else
echo "Deploying snapshot"
saveGitCredentials
./gradlew artifactoryPublish -Dsnapshot=true -Dbuild.number="${TRAVIS_BUILD_NUMBER}"
fi
else
echo "Verify"
./gradlew clean assemble && ./gradlew check --info
fi