Play Store: implement biweekly auto-deploys

This commit is contained in:
Braden Farmer 2021-01-02 23:48:40 -07:00
parent ac5c45f333
commit d3ac2658a8
2 changed files with 27 additions and 19 deletions

View File

@ -39,6 +39,8 @@ android {
}
}
targetSdkVersion 29
versionCode System.currentTimeSeconds().toInteger()
versionName "${getManifestAttribute("versionName")}_GIT"
}
productFlavors {
@ -70,6 +72,8 @@ android {
}
playStoreNormal {
minSdkVersion 21
versionCode getPlayStoreVersionCode()
versionName getPlayStoreVersionName()
resValue "string", "app_name", "RetroArch"
buildConfigField "boolean", "PLAY_STORE_BUILD", "true"
@ -78,6 +82,8 @@ android {
}
playStorePlus {
minSdkVersion 26
versionCode getPlayStoreVersionCode()
versionName getPlayStoreVersionName()
applicationIdSuffix '.aarch64'
resValue "string", "app_name", "RetroArch Plus"
@ -140,3 +146,24 @@ def dynamicFeatures = file("dynamic_features.gradle")
if(dynamicFeatures.exists()) {
apply from: "dynamic_features.gradle"
}
static int getPlayStoreVersionCode() {
def baseVersion = getManifestAttribute("versionCode").toInteger()
def baseTime = 1609632000
def halfWeek = 302400
def increment = (System.currentTimeSeconds() - baseTime) / halfWeek
return baseVersion + increment
}
static String getPlayStoreVersionName() {
def versionName = getManifestAttribute("versionName")
return "$versionName (${new Date().format("yyyy-MM-dd")})"
}
static String getManifestAttribute(String attribute) {
def manifest = new XmlParser().parse("AndroidManifest.xml")
return manifest.attributes().find {
((String) it.key).contains(attribute)
}.value
}

View File

@ -1,19 +0,0 @@
#!/usr/bin/python
import time
from xml.dom.minidom import parse
dom1 = parse("AndroidManifest.xml")
oldVersion = dom1.documentElement.getAttribute("android:versionCode")
versionNumbers = oldVersion.split('.')
versionName = dom1.documentElement.getAttribute("android:versionName")
versionName = versionName + "_GIT"
versionNumbers[-1] = unicode(int(time.time()))
dom1.documentElement.setAttribute("android:versionCode", u'.'.join(versionNumbers))
dom1.documentElement.setAttribute("android:versionName", versionName)
with open("AndroidManifest.xml", 'wb') as f:
for line in dom1.toxml("utf-8"):
f.write(line)