Skip to content

Commit 2bb6d7d

Browse files
committed
Update build script for publishing snapshots
1 parent 5ce54de commit 2bb6d7d

File tree

2 files changed

+57
-11
lines changed

2 files changed

+57
-11
lines changed

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
version = 9.2.0
1+
version = 9.2.0-SNAPSHOT
22
group = com.graphql-java-kickstart
33

44
PROJECT_NAME = graphql-java-servlet

travis-build.sh

Lines changed: 56 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,17 +14,63 @@ EOL
1414
chmod 600 $HOME/.netrc
1515
}
1616

17-
if [ "${TRAVIS_PULL_REQUEST}" = "false" ] && [ "${TRAVIS_BRANCH}" = "master" ] && [ "${RELEASE}" = "true" ]; then
18-
saveGitCredentials
19-
git checkout -f ${TRAVIS_BRANCH}
20-
if [ "${RELEASE}" = "true" ]; then
21-
echo "Deploying release to Bintray"
22-
# ./gradlew clean assemble release -Prelease.useAutomaticVersion=true && ./gradlew check --info
23-
./gradlew clean assemble && ./gradlew check --info && ./gradlew bintrayUpload -x check --info
17+
getVersion() {
18+
./gradlew properties -q | grep "version:" | grep -v "kotlin_version:" | awk '{print $2}' | tr -d '[:space:]'
19+
}
20+
21+
removeSnapshots() {
22+
sed -i 's/-SNAPSHOT//' gradle.properties
23+
}
24+
25+
commitRelease() {
26+
local APP_VERSION=$(getVersion)
27+
git commit -a -m "Update version for release"
28+
git tag -a "v${APP_VERSION}" -m "Tag release version"
29+
}
30+
31+
bumpVersion() {
32+
echo "Bump version number"
33+
local APP_VERSION=$(getVersion | xargs)
34+
local SEMANTIC_REGEX='^([0-9]+)\.([0-9]+)(\.([0-9]+))?$'
35+
if [[ ${APP_VERSION} =~ ${SEMANTIC_REGEX} ]]; then
36+
if [[ ${BASH_REMATCH[4]} ]]; then
37+
nextVersion=$((BASH_REMATCH[4] + 1))
38+
nextVersion="${BASH_REMATCH[1]}.${BASH_REMATCH[2]}.${nextVersion}-SNAPSHOT"
2439
else
25-
echo "Deploying snapshot to Bintray"
26-
./gradlew artifactoryPublish && ./gradlew check --info
40+
nextVersion=$((BASH_REMATCH[2] + 1))
41+
nextVersion="${BASH_REMATCH[1]}.${nextVersion}-SNAPSHOT"
2742
fi
43+
44+
echo "Next version: ${nextVersion}"
45+
sed -i -E "s/^version(\s)?=.*/version=${nextVersion}/" gradle.properties
46+
else
47+
echo "No semantic version and therefore cannot publish to maven repository: '${APP_VERSION}'"
48+
fi
49+
}
50+
51+
commitNextVersion() {
52+
git commit -a -m "Update version for release"
53+
}
54+
55+
if [ "${TRAVIS_PULL_REQUEST}" = "false" ] && [ "${TRAVIS_BRANCH}" = "master" ]; then
56+
if [ "${RELEASE}" = "true" ]; then
57+
echo "Deploying release to Bintray"
58+
saveGitCredentials
59+
git checkout -f ${TRAVIS_BRANCH}
60+
removeSnapshots
61+
62+
./gradlew clean assemble && ./gradlew check --info && ./gradlew bintrayUpload -x check --info
63+
64+
commitRelease
65+
bumpVersion
66+
commitNextVersion
67+
git push --follow-tags
68+
else
69+
echo "Deploying snapshot"
70+
saveGitCredentials
71+
./gradlew artifactoryPublish -Dsnapshot=true -Dbuild.number="${TRAVIS_BUILD_NUMBER}"
72+
fi
2873
else
29-
./gradlew check --info
74+
echo "Verify"
75+
./gradlew clean assemble && ./gradlew check --info
3076
fi

0 commit comments

Comments
 (0)