Bladeren bron

Update the versioning logic for the Godot Android Editor

This is necessary to separate subsequent uploads to the Google Play store as each upload needs to increment the version code.
Fredia Huya-Kouadio 3 jaren geleden
bovenliggende
commit
67b38d0ac2
2 gewijzigde bestanden met toevoegingen van 44 en 5 verwijderingen
  1. 23 3
      platform/android/java/app/config.gradle
  2. 21 2
      platform/android/java/editor/build.gradle

+ 23 - 3
platform/android/java/app/config.gradle

@@ -127,16 +127,36 @@ ext.generateGodotLibraryVersion = { List<String> requiredKeys ->
         if (requiredKeys.empty) {
         if (requiredKeys.empty) {
             libraryVersionName = map.values().join(".")
             libraryVersionName = map.values().join(".")
             try {
             try {
+                if (map.containsKey("status")) {
+                    int statusCode = 0
+                    String statusValue = map["status"]
+                    if (statusValue == null) {
+                        statusCode = 0
+                    } else if (statusValue.startsWith("alpha")) {
+                        statusCode = 1
+                    } else if (statusValue.startsWith("beta")) {
+                        statusCode = 2
+                    } else if (statusValue.startsWith("rc")) {
+                        statusCode = 3
+                    } else if (statusValue.startsWith("stable")) {
+                        statusCode = 4
+                    } else {
+                        statusCode = 0
+                    }
+
+                    libraryVersionCode = statusCode
+                }
+
                 if (map.containsKey("patch")) {
                 if (map.containsKey("patch")) {
-                    libraryVersionCode = Integer.parseInt(map["patch"])
+                    libraryVersionCode += Integer.parseInt(map["patch"]) * 10
                 }
                 }
 
 
                 if (map.containsKey("minor")) {
                 if (map.containsKey("minor")) {
-                    libraryVersionCode += (Integer.parseInt(map["minor"]) * 100)
+                    libraryVersionCode += (Integer.parseInt(map["minor"]) * 1000)
                 }
                 }
 
 
                 if (map.containsKey("major")) {
                 if (map.containsKey("major")) {
-                    libraryVersionCode += (Integer.parseInt(map["major"]) * 10000)
+                    libraryVersionCode += (Integer.parseInt(map["major"]) * 100000)
                 }
                 }
             } catch (NumberFormatException ignore) {
             } catch (NumberFormatException ignore) {
                 libraryVersionCode = 1
                 libraryVersionCode = 1

+ 21 - 2
platform/android/java/editor/build.gradle

@@ -12,6 +12,25 @@ dependencies {
     implementation "androidx.window:window:1.0.0"
     implementation "androidx.window:window:1.0.0"
 }
 }
 
 
+ext {
+    // Build number added as a suffix to the version code, and incremented for each build/upload to
+    // the Google Play store.
+    // This should be reset on each stable release of Godot.
+    editorBuildNumber = 0
+    // Value by which the Godot version code should be offset by to make room for the build number
+    editorBuildNumberOffset = 100
+}
+
+def generateVersionCode() {
+    int libraryVersionCode = getGodotLibraryVersionCode()
+    return (libraryVersionCode * editorBuildNumberOffset) + editorBuildNumber
+}
+
+def generateVersionName() {
+    String libraryVersionName = getGodotLibraryVersionName()
+    return libraryVersionName + ".$editorBuildNumber"
+}
+
 android {
 android {
     compileSdkVersion versions.compileSdk
     compileSdkVersion versions.compileSdk
     buildToolsVersion versions.buildTools
     buildToolsVersion versions.buildTools
@@ -20,8 +39,8 @@ android {
     defaultConfig {
     defaultConfig {
         // The 'applicationId' suffix allows to install Godot 3.x(v3) and 4.x(v4) on the same device
         // The 'applicationId' suffix allows to install Godot 3.x(v3) and 4.x(v4) on the same device
         applicationId "org.godotengine.editor.v4"
         applicationId "org.godotengine.editor.v4"
-        versionCode getGodotLibraryVersionCode()
-        versionName getGodotLibraryVersionName()
+        versionCode generateVersionCode()
+        versionName generateVersionName()
         minSdkVersion versions.minSdk
         minSdkVersion versions.minSdk
         targetSdkVersion versions.targetSdk
         targetSdkVersion versions.targetSdk