Skip to content

Commit

Permalink
Correct signingconfig for Android
Browse files Browse the repository at this point in the history
  • Loading branch information
Christiaan de Die le Clercq committed Aug 3, 2020
1 parent 561b895 commit 0fd0f0f
Show file tree
Hide file tree
Showing 3 changed files with 94 additions and 54 deletions.
81 changes: 79 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,81 @@
# android-ci
Helper library to automatically build and publish a Android app via CI.
[ ![Download](https://api.bintray.com/packages/uncinc/android-ci/UncIncAndroidCIPlugin/images/download.svg) ](https://bintray.com/uncinc/android-ci/UncIncAndroidCIPlugin/_latestVersion)

Helper library to automatically build [~~and publish~~](https://github.com/uncinc/android-ci/issues/1) an Android app via CI.

In early alpha stage currently. Documentation will follow.
The current library is an internal testing alpha release, more documentation and features will be available in the future. Feature requests are welcome, please submit a Github issue.

## Setup
1. Include the repository, to your root build.gradle add the following contents:
```gradle
buildscript {
repositories {
maven {
url "https://dl.bintray.com/uncinc/android-ci"
}
}
dependencies {
classpath 'nl.uncinc.androidci:UncIncAndroidCI:0.2'
}
}
```
2. In your app's build.gradle add the following before the `android {` block:
```
apply plugin: 'nl.uncinc.androidci'
```
3. Replace version code, version name, and the signing config for the release build in the Android config:
```
android {
defaultConfig {
versionCode project.ext.androidciconfig.getVersionCode()
versionName project.ext.androidciconfig.getVersionName()
}
buildTypes {
release {
signingConfig project.ext.androidciconfig.getSigningConfig(project)
}
}
}
```
4. Create a signingProperties file in the build context (example, this as signing.properties):
```
storePassword=keystorePassword
keyPassword=keyPassword
keyAlias=key0
storeFile=/Full/Path/To/keystore.jks
```
5. For building the app use:
```
./gradlew -Pandroidci.signingProperties=/Full/Path/To/signing.properties -Pandroidci.versionCode=2
```

# Possible properties
| Property | Purpose | Default Value |
|-----------------------------|----------------------------------------------------------------------------------|--------------------------------------------------------------------------------|
| androidci.signingProperties | Full path to the file with the signing configuration. Should be available to CI. | android-app-signing.properties (and if it does not exist. The Debug build key) |
| androidci.versionCode | Android versionCode, use an Integer value | 1 |
| androidci.versionName | Android versionName, should be a String | Git hash of the repo |

# License
MIT License

Copyright (c) 2020 Unc Inc

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
12 changes: 8 additions & 4 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ plugins {
}

group 'nl.uncinc.androidci'
version '1.0'
version '0.2'
sourceCompatibility = 1.8

repositories {
Expand Down Expand Up @@ -35,7 +35,7 @@ apply plugin: 'maven'
uploadArchives {
repositories {
mavenDeployer {
repository(url: uri('/Users/techwolf12/local-gradle-repo'))
repository(url: uri('/Users/techwolf12/gradletest'))
}
}
}
Expand All @@ -45,10 +45,14 @@ bintray {
key = project.hasProperty('bintrayApiKey') ? project.property('bintrayApiKey') : System.getenv('BINTRAY_API_KEY')
configurations = ['archives']
pkg {
repo = 'maven'
name = 'android-ci'
repo = 'android-ci'
name = 'UncIncAndroidCIPlugin'
userOrg = 'uncinc'
licenses = ['MIT']
vcsUrl = 'https://github.com/uncinc/android-ci.git'
version {
name = '0.2'
vcsTag = '0.2'
}
}
}
55 changes: 7 additions & 48 deletions src/main/groovy/nl/uncinc/androidci/UncIncAndroidCIPlugin.groovy
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package nl.uncinc.androidci

import com.android.builder.model.SigningConfig
import com.android.build.gradle.internal.dsl.SigningConfig
import org.gradle.api.Plugin
import org.gradle.api.Project

Expand Down Expand Up @@ -51,53 +51,12 @@ class UncIncAndroidCIPlugin implements Plugin<Project> {
return androidci.versionName
}

SigningConfig getSigningConfig() {
def signingConfig = new SigningConfig() {
@Override
String getName() {
return "androidcisigning"
}

@Override
File getStoreFile() {
return file(androidci.keystoreProperties['storeFile'])
}

@Override
String getStorePassword() {
return androidci.keystoreProperties['storePassword']
}

@Override
String getKeyAlias() {
return androidci.keystoreProperties['keyAlias']
}

@Override
String getKeyPassword() {
return androidci.keystoreProperties['keyPassword']
}

@Override
String getStoreType() {
return androidci.keystoreProperties['storeFileType']
}

@Override
boolean isV1SigningEnabled() {
return true
}

@Override
boolean isV2SigningEnabled() {
return true
}

@Override
boolean isSigningReady() {
return true
}
}
SigningConfig getSigningConfig(Project project) {
def signingConfig = new SigningConfig()
signingConfig.storeFile = project.file(androidci.keystoreProperties['storeFile'])
signingConfig.storePassword = androidci.keystoreProperties['storePassword']
signingConfig.keyAlias = androidci.keystoreProperties['keyAlias']
signingConfig.keyPassword = androidci.keystoreProperties['keyPassword']
return signingConfig
}

Expand Down

0 comments on commit 0fd0f0f

Please sign in to comment.