-
-
Notifications
You must be signed in to change notification settings - Fork 44
Expand file tree
/
Copy pathversioning.gradle.kts
More file actions
36 lines (30 loc) · 1.15 KB
/
versioning.gradle.kts
File metadata and controls
36 lines (30 loc) · 1.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import java.util.Properties
import java.text.SimpleDateFormat
import java.util.Date
val versionProps = Properties()
val versionPropertiesFile = rootProject.file("version.properties")
if (versionPropertiesFile.exists()) {
versionPropertiesFile.inputStream().use { versionProps.load(it) }
} else {
throw GradleException("Root project version.properties not found! Please ensure it exists with MAJOR, MINOR, PATCH values.")
}
val appMajorVersion = versionProps.getProperty("MAJOR").toInt()
val appMinorVersion = versionProps.getProperty("MINOR").toInt()
val appPatchVersion = versionProps.getProperty("PATCH").toInt()
fun getCurrentTimestamp(): String {
val sdf = SimpleDateFormat("yyyyMMddHHmm")
return sdf.format(Date())
}
fun appVersionCode(): Int {
val ciBuildNumber = System.getenv("GITHUB_RUN_NUMBER")
return if (ciBuildNumber != null) {
ciBuildNumber.toInt() + 1000
} else {
1017 // Local build version code
}
}
fun appVersionName(): String {
return "${appMajorVersion}.${appMinorVersion}.${appPatchVersion}"
}
project.extra.set("appVersionCode", ::appVersionCode)
project.extra.set("appVersionName", ::appVersionName)