Skip to content

Instantly share code, notes, and snippets.

@mreichelt
Last active January 22, 2019 12:47
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mreichelt/9be80545bb0c1f8c1ea20631c5dd1460 to your computer and use it in GitHub Desktop.
Save mreichelt/9be80545bb0c1f8c1ea20631c5dd1460 to your computer and use it in GitHub Desktop.
Example of build.gradle where the signing config comes from system environment variables
android {
signingConfigs {
release {
// export these as environment variables like ORG_GRADLE_PROJECT_MYAPP_RELEASE_STORE_FILE
// (prefix 'ORG_GRADLE_PROJECT_' is needed for Gradle project properties)
storeFile rootProject.file('app/' + project.findProperty('MYAPP_RELEASE_STORE_FILE'))
storePassword project.findProperty('MYAPP_RELEASE_STORE_PASSWORD')
keyAlias project.findProperty('MYAPP_RELEASE_KEY_ALIAS')
keyPassword project.findProperty('MYAPP_RELEASE_KEY_PASSWORD')
}
}
buildTypes {
release {
signingConfig signingConfigs.release
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}
task failIfSigningConfigMissing << {
if (!project.hasProperty('MYAPP_RELEASE_STORE_FILE')) {
throw new GradleException('release signing config missing')
}
}
gradle.projectsEvaluated {
assembleRelease.dependsOn failIfSigningConfigMissing
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment