Skip to content
This repository has been archived by the owner on May 14, 2022. It is now read-only.

Commit

Permalink
More grade release automation work for #15
Browse files Browse the repository at this point in the history
  • Loading branch information
pazaan committed May 22, 2016
1 parent 6adea8b commit bcb91d8
Show file tree
Hide file tree
Showing 6 changed files with 68 additions and 6 deletions.
4 changes: 3 additions & 1 deletion app/app.iml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<module external.linked.project.id=":app" external.linked.project.path="$MODULE_DIR$" external.root.project.path="$MODULE_DIR$/.." external.system.id="GRADLE" external.system.module.group="640gAndroidUploader" external.system.module.version="0.2.0" type="JAVA_MODULE" version="4">
<module external.linked.project.id=":app" external.linked.project.path="$MODULE_DIR$" external.root.project.path="$MODULE_DIR$/.." external.system.id="GRADLE" external.system.module.group="640gAndroidUploader" external.system.module.version="0.2.1" type="JAVA_MODULE" version="4">
<component name="FacetManager">
<facet type="android-gradle" name="Android-Gradle">
<configuration>
Expand Down Expand Up @@ -106,6 +106,8 @@
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/symbols" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/transforms" />
<excludeFolder url="file://$MODULE_DIR$/build/outputs" />
<excludeFolder url="file://$MODULE_DIR$/build/reports" />
<excludeFolder url="file://$MODULE_DIR$/build/test-results" />
<excludeFolder url="file://$MODULE_DIR$/build/tmp" />
</content>
<orderEntry type="jdk" jdkName="Android API 21 Platform" jdkType="Android SDK" />
Expand Down
62 changes: 62 additions & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,25 @@ plugins {

apply plugin: 'com.android.application'

def gitVersion() {
def process = ['sh', '-c', 'git tag -l | grep -c ".*" -'].execute().text.trim()
return process.toInteger() + 1
}

android {
compileSdkVersion 21
buildToolsVersion "23.0.3"

applicationVariants.all { variant ->
variant.resValue "string", "versionName", variant.versionName
}

defaultConfig {
applicationId "info.nightscout.android"
minSdkVersion 15
targetSdkVersion 21
versionName project.properties['version']
versionCode gitVersion()
}

buildTypes {
Expand All @@ -28,8 +39,59 @@ android {
}
}

task signRelease << {
def command = [
'jarsigner',
'-verbose',
'-sigalg',
'SHA1withRSA',
'-digestalg',
'SHA1',
'-keystore',
'/Users/lgoedhart/keystores/nightscout_android.jks',
'app/build/outputs/apk/app-release-unsigned.apk',
'nightscoutandroidkey'
]

def proc = new ProcessBuilder(command)
.redirectOutput(ProcessBuilder.Redirect.INHERIT)
.redirectInput(ProcessBuilder.Redirect.INHERIT)
.redirectError(ProcessBuilder.Redirect.INHERIT)
.start()

proc.waitFor()

if (0 != proc.exitValue()) {
throw new RuntimeException("Could not sign APK.")
}
}

task zipalignRelease << {
def command = [
'/Users/lgoedhart/Library/Android/sdk/build-tools/23.0.3/zipalign',
'-v',
'4',
'app/build/outputs/apk/app-release-unsigned.apk',
'app/build/outputs/apk/640g-android-uploader.apk'
]

def proc = new ProcessBuilder(command)
.redirectOutput(ProcessBuilder.Redirect.INHERIT)
.redirectInput(ProcessBuilder.Redirect.INHERIT)
.redirectError(ProcessBuilder.Redirect.INHERIT)
.start()

proc.waitFor()

if (0 != proc.exitValue()) {
throw new RuntimeException("Could not align APK.")
}
}

release {
tagTemplate = 'v${version}'
buildTasks = ['assembleRelease']
afterReleaseBuild.dependsOn 'signRelease', 'zipalignRelease'
}

dependencies {
Expand Down
2 changes: 1 addition & 1 deletion app/gradle.properties
Original file line number Diff line number Diff line change
@@ -1 +1 @@
version=0.2.1
version=0.2.0-SNAPSHOT
3 changes: 1 addition & 2 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="info.nightscout.android"
android:versionCode="1"
android:versionName="@string/version" >
>

<uses-sdk
android:maxSdkVersion="21"
Expand Down
1 change: 0 additions & 1 deletion app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
<string name="eula_title">Disclaimer</string>
<string name="eula_accept">Accept</string>
<string name="eula_refuse">Refuse</string>
<string name="version">0.2.0</string>
<style name="ButtonText">
<item name="android:layout_width">fill_parent</item>
<item name="android:layout_height">wrap_content</item>
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/xml/preferences.xml
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
<PreferenceCategory android:title="App Version">
<Preference
android:key="version"
android:title="@string/version" />
android:title="@string/versionName" />
</PreferenceCategory>
<PreferenceCategory android:title="Debug">
<ListPreference
Expand Down

0 comments on commit bcb91d8

Please sign in to comment.