Commit 70bb7152 authored by Daniel Wolf's avatar Daniel Wolf
Browse files
parents aa7d98de dbb292cc
......@@ -7,4 +7,6 @@ test-build-deploy:
stage: test
script:
- ./gradlew clean assembleRelease sourcesJar test --stacktrace
- ./gradlew publish --stacktrace
\ No newline at end of file
- ./gradlew publish --stacktrace
only:
- /^v([0-9]+\.?)+[0-9]$/
\ No newline at end of file
......@@ -3,10 +3,21 @@ apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
group = 'com.frostnerd.utilskt'
version = '3.1.17'
ext {
libraryGroupId = group
libraryArtifactId = rootProject.name
libraryVersion = '3.1.17'
}
task bumpPatch() {
dependsOn("bumpPatchVersion")
}
task bumpMinor() {
dependsOn("bumpMinorVersion")
}
task bumpMajor() {
dependsOn("bumpMajorVersion")
}
android {
......@@ -49,7 +60,7 @@ android {
exclude 'META-INF/ASL2.0'
}
compileOptions {
kotlinOptions.freeCompilerArgs += ['-module-name', "$libraryGroupId.$libraryArtifactId"]
kotlinOptions.freeCompilerArgs += ['-module-name', "$group.$libraryArtifactId"]
}
}
......@@ -79,12 +90,13 @@ task sourcesJar(type: Jar) {
classifier = 'sources'
}
afterEvaluate {
publishing {
publications {
aar(MavenPublication) {
groupId libraryGroupId
version libraryVersion
groupId group
version version
artifactId libraryArtifactId
artifact("$buildDir/outputs/aar/library-release.aar")
......@@ -117,4 +129,67 @@ afterEvaluate {
}
}
}
publish.dependsOn("assembleRelease", "sourcesJar")
\ No newline at end of file
publish.dependsOn("assembleRelease", "sourcesJar")
class Version {
private int major
private int minor
private int patch
Version(String version) {
def (major, minor, patch) = version.tokenize('.')
this.major = major.toInteger()
this.minor = minor.toInteger()
this.patch = patch.toInteger()
}
void bumpMajor() {
major += 1
minor = 0
patch = 0
}
void bumpMinor() {
minor += 1
patch = 0
}
void bumpPatch() {
patch += 1
}
String getName() { "$major.$minor.$patch" }
}
tasks.addRule("Pattern: bump<TYPE>Version") { String taskName ->
if (taskName.matches("bump(Major|Minor|Patch)Version")) {
task(taskName) {
doLast {
String type = (taskName - 'bump' - 'Version')
println "Bumping ${type.toLowerCase()} version"
def parsedVersion = new Version(version)
parsedVersion."bump$type"()
println "${version} => ${parsedVersion.name}"
def updated = buildFile.getText()
updated = updated.replaceFirst("version\\s*=\\s*'$version'", "version = '${parsedVersion.name}'")
buildFile.setText(updated)
exec {
commandLine("git", "add", "build.gradle")
}
exec {
commandLine("git", "commit", "-m", "\"Bump version to ${parsedVersion.name}\"")
}
exec {
commandLine("git", "tag", "v${parsedVersion.name}")
}
exec {
commandLine("git", "push", "origin", "v${parsedVersion.name}")
}
}
}
}
}
\ No newline at end of file
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment