Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@alexfu
Last active August 29, 2015 14:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alexfu/27715c8a1891085adbd2 to your computer and use it in GitHub Desktop.
Save alexfu/27715c8a1891085adbd2 to your computer and use it in GitHub Desktop.
Examples of how to streamline releases with your Gradle based Android project
/**
* This example demonstrates how to create a build task
* for publishing a beta to HockeyApp in addition to
* tagging and pushing a beta release to your remote git
* repo using the gradle-git plugin.
*/
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'org.ajoberstar:gradle-git:1.2.0'
classpath 'de.felixschulze.gradle:gradle-hockeyapp-plugin:3.0.1'
}
}
apply plugin: 'org.ajoberstar.grgit'
apply plugin: 'de.felixschulze.gradle.hockeyapp'
android {
...
}
hockeyapp {
...
}
tasks.whenTaskAdded { task ->
if (task.name.equals("uploadBetaToHockeyApp")) {
tasks.releaseBeta.dependsOn task
}
}
task releaseBeta << {
// Ex: v1.2.3.45
def tagName = "v${android.defaultConfig.versionName}.${android.defaultConfig.versionCode}"
grgit.tag.add(name: tagName, message: "Beta release ${tagName}")
grgit.push(refsOrSpecs: [tagName])
}
/**
* This example demonstrates how to create a build task
* for tagging and pushing a beta release to your remote
* git repo using the gradle-git plugin.
*/
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'org.ajoberstar:gradle-git:1.2.0'
}
}
apply plugin: 'org.ajoberstar.grgit'
android {
...
}
task releaseBeta << {
// Ex: v1.2.3.45
def tagName = "v${android.defaultConfig.versionName}.${android.defaultConfig.versionCode}"
grgit.tag.add(name: tagName, message: "Beta release ${tagName}")
grgit.push(refsOrSpecs: [tagName])
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment