mirror of
https://github.com/izzy2lost/PSX2.git
synced 2026-07-05 15:18:36 -07:00
Add auto updating version code
This commit is contained in:
@@ -21,3 +21,4 @@ build/
|
||||
*.exe
|
||||
/WARP.md
|
||||
*.aab
|
||||
*.properties
|
||||
|
||||
+50
-1
@@ -2,6 +2,29 @@ plugins {
|
||||
id 'com.android.application'
|
||||
}
|
||||
|
||||
// Function to get and increment version code
|
||||
def getVersionCode() {
|
||||
def versionFile = file('version.properties')
|
||||
def versionCode = 3 // Starting version code
|
||||
|
||||
if (versionFile.exists()) {
|
||||
def props = new Properties()
|
||||
props.load(new FileInputStream(versionFile))
|
||||
versionCode = props['VERSION_CODE'] as int
|
||||
}
|
||||
|
||||
// Increment version code for AAB builds
|
||||
if (gradle.startParameter.taskNames.any { it.toLowerCase().contains('bundle') }) {
|
||||
versionCode++
|
||||
def props = new Properties()
|
||||
props['VERSION_CODE'] = versionCode.toString()
|
||||
props.store(versionFile.newWriter(), null)
|
||||
println "Auto-incremented version code to: ${versionCode}"
|
||||
}
|
||||
|
||||
return versionCode
|
||||
}
|
||||
|
||||
android {
|
||||
namespace 'com.izzy2lost.psx2'
|
||||
compileSdk 36
|
||||
@@ -11,7 +34,7 @@ android {
|
||||
applicationId "com.izzy2lost.psx2"
|
||||
minSdk 26
|
||||
targetSdk 36
|
||||
versionCode 2
|
||||
versionCode getVersionCode()
|
||||
versionName "1.0.1"
|
||||
// APK
|
||||
setProperty("archivesBaseName","PSX2_${versionCode}_${new Date().format('yyyyMMddHHmm')}")
|
||||
@@ -67,6 +90,32 @@ android {
|
||||
}
|
||||
}
|
||||
|
||||
// Manual version increment tasks
|
||||
task incrementVersion {
|
||||
doLast {
|
||||
def versionFile = file('version.properties')
|
||||
def versionCode = 3
|
||||
|
||||
if (versionFile.exists()) {
|
||||
def props = new Properties()
|
||||
props.load(new FileInputStream(versionFile))
|
||||
versionCode = props['VERSION_CODE'] as int
|
||||
}
|
||||
|
||||
versionCode++
|
||||
def props = new Properties()
|
||||
props['VERSION_CODE'] = versionCode.toString()
|
||||
props.store(versionFile.newWriter(), null)
|
||||
println "Incremented version code to: ${versionCode}"
|
||||
}
|
||||
}
|
||||
|
||||
task showVersion {
|
||||
doLast {
|
||||
println "Current version code: ${getVersionCode()}"
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation 'androidx.appcompat:appcompat:1.7.1'
|
||||
implementation 'com.google.android.material:material:1.14.0-alpha04'
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:versionCode="1"
|
||||
android:versionName="1.0"
|
||||
android:installLocation="preferExternal"
|
||||
tools:ignore="MissingLeanbackLauncher">
|
||||
|
||||
|
||||
Reference in New Issue
Block a user