Skip to content

Commit

Permalink
Add named APKs and version coding to use RCs
Browse files Browse the repository at this point in the history
  • Loading branch information
josh-griffin committed May 10, 2021
1 parent 290a132 commit ba44a3f
Showing 1 changed file with 20 additions and 2 deletions.
22 changes: 20 additions & 2 deletions android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ apply from: '../../node_modules/react-native-unimodules/gradle.groovy'
apply from: "../../node_modules/@bugsnag/react-native/bugsnag-react-native.gradle"

import com.android.build.OutputFile
import groovy.json.JsonSlurper

/**
* The react.gradle file registers a task for each build variant (e.g. bundleDebugJsAndAssets
Expand Down Expand Up @@ -125,9 +126,26 @@ def jscFlavor = 'org.webkit:android-jsc:+'
*/
def enableHermes = project.ext.react.get("enableHermes", true);

def getAppVersion() {
def inputFile = new File("../package.json")
def packageJson = new JsonSlurper().parseText(inputFile.text)
return packageJson["version"]
}

def getAppName() {
def inputFile = new File("../package.json")
def packageJson = new JsonSlurper().parseText(inputFile.text)
return packageJson["name"]
}

def (appVersion, provisional) = getAppVersion().tokenize('-rc')
def (major, minor, patch) = appVersion.tokenize('.')
def appVersionCode = ((major.toInteger() * 10000000) + (minor.toInteger() * 100000) + (patch.toInteger() * 100) + (provisional != null ? provisional.toInteger() : 99))

android {
ndkVersion rootProject.ext.ndkVersion
compileSdkVersion rootProject.ext.compileSdkVersion
setProperty("archivesBaseName", (getAppName() + "-" + getAppVersion()).replace(".","_"))

compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
Expand All @@ -142,8 +160,8 @@ android {
applicationId "com.msupplycoldchain"
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
versionCode 1
versionName "0.0.2"
versionCode appVersionCode
versionName getAppVersion()
multiDexEnabled true
}
splits {
Expand Down

0 comments on commit ba44a3f

Please sign in to comment.