Skip to content

Commit f247c89

Browse files
git based versioning (#71)
1 parent 152c1bb commit f247c89

File tree

5 files changed

+35
-12
lines changed

5 files changed

+35
-12
lines changed

.travis.yml

+3-7
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,11 @@
1414
# limitations under the License.
1515
#
1616
---
17+
install:
18+
- true
1719
language: java
1820
jdk:
19-
- oraclejdk8
20-
addons:
21-
apt:
22-
packages:
23-
- oracle-java8-installer
24-
dist: trusty
25-
sudo: false
21+
- openjdk8
2622
script: ci/buildViaTravis.sh
2723
cache:
2824
directories:

build.gradle

+25
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,21 @@
1616

1717
plugins {
1818
id 'com.gradle.build-scan'
19+
id 'com.palantir.git-version'
1920
id 'io.spring.dependency-management' apply false
2021
id 'com.jfrog.bintray' apply false
2122
id 'com.jfrog.artifactory' apply false
2223
id 'org.jetbrains.kotlin.jvm' apply false
2324
}
2425

26+
def versionSuffix = versionSuffix()
27+
2528
allprojects {
2629
dependencyLocking {
2730
lockAllConfigurations()
2831
}
32+
project.version += versionSuffix
33+
println "version: ${project.version}"
2934
}
3035

3136
subprojects {
@@ -81,3 +86,23 @@ buildScan {
8186
termsOfServiceUrl = 'https://gradle.com/terms-of-service'
8287
termsOfServiceAgree = 'yes'
8388
}
89+
90+
def versionSuffix() {
91+
def versionSuffix = ''
92+
def branchName = project.findProperty('branch');
93+
if (branchName == null) {
94+
def details = versionDetails()
95+
if (details != null) {
96+
branchName = details.branchName
97+
}
98+
}
99+
100+
if (branchName != null) {
101+
if (branchName == 'master') {
102+
versionSuffix = '-SNAPSHOT'
103+
} else {
104+
versionSuffix = "-${branchName.replace("/", "-")}-SNAPSHOT"
105+
}
106+
}
107+
return versionSuffix
108+
}

ci/buildViaTravis.sh

+4-4
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@
33

44
if [ "$TRAVIS_PULL_REQUEST" != "false" ]; then
55
echo -e "Build Pull Request #$TRAVIS_PULL_REQUEST => Branch [$TRAVIS_BRANCH]"
6-
./gradlew build
6+
./gradlew -Pbranch="${TRAVIS_BRANCH}" build
77
elif [ "$TRAVIS_PULL_REQUEST" == "false" ] && [ "$TRAVIS_TAG" == "" ]; then
88
echo -e 'Build Branch with Snapshot => Branch ['$TRAVIS_BRANCH']'
9-
./gradlew -PbintrayUser="${bintrayUser}" -PbintrayKey="${bintrayKey}" build artifactoryPublish --stacktrace
9+
./gradlew -PbintrayUser="${bintrayUser}" -PbintrayKey="${bintrayKey}" -Pbranch="${TRAVIS_BRANCH}" build artifactoryPublish --stacktrace
1010
elif [ "$TRAVIS_PULL_REQUEST" == "false" ] && [ "$TRAVIS_TAG" != "" ]; then
1111
echo -e 'Build Branch for Release => Branch ['$TRAVIS_BRANCH'] Tag ['$TRAVIS_TAG']'
12-
./gradlew -Pversion="$TRAVIS_TAG" -PbintrayUser="${bintrayUser}" -PbintrayKey="${bintrayKey}" build bintrayUpload --stacktrace
12+
./gradlew -PbintrayUser="${bintrayUser}" -PbintrayKey="${bintrayKey}" build bintrayUpload --stacktrace
1313
else
1414
echo -e 'WARN: Should not be here => Branch ['$TRAVIS_BRANCH'] Tag ['$TRAVIS_TAG'] Pull Request ['$TRAVIS_PULL_REQUEST']'
15-
./gradlew build
15+
./gradlew -Pbranch="${TRAVIS_BRANCH}" build
1616
fi

gradle.properties

+2-1
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,14 @@
1515
#
1616

1717
group=io.rsocket.kotlin
18-
version=0.9.7-SNAPSHOT
18+
version=0.9.7
1919

2020
buildScanPluginVersion=2.4.1
2121
dependencyManagementPluginVersion=1.0.8.RELEASE
2222
bintrayPluginVersion=1.8.4
2323
artifactoryPluginVersion=4.9.8
2424
kotlinPluginVersion=1.3.50
25+
gitPluginVersion=0.12.0-rc2
2526

2627
nettyBufferVersion=4.1.37.Final
2728
jsr305Version=3.0.2

settings.gradle

+1
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ pluginManagement {
2121
id 'com.jfrog.bintray' version "${bintrayPluginVersion}"
2222
id 'com.jfrog.artifactory' version "${artifactoryPluginVersion}"
2323
id 'org.jetbrains.kotlin.jvm' version "${kotlinPluginVersion}"
24+
id "com.palantir.git-version" version "${gitPluginVersion}"
2425
}
2526
}
2627

0 commit comments

Comments
 (0)