mirror of
https://github.com/kiwix/kiwix-android.git
synced 2025-08-03 10:46:53 -04:00
Fixed: Reproducible Builds.
* To generate the APK for a specific date, set the "RELEASE_DATE" environment variable in the format `YYYY-MM-DD`. The APK will be generated for the specified date. If the variable is not set, the APK will be generated for the current date.
This commit is contained in:
parent
359a1fc4bc
commit
29616b1cf7
@ -23,9 +23,18 @@ fun String.getVersionCode(): Int {
|
||||
// the date when the automatic version code generation started
|
||||
val lastDate = LocalDate.of(2024, 7, 17)
|
||||
|
||||
// Get the current date. If the "RELEASE_DATE" environment variable is set(in YYYY-MM-DD format).
|
||||
// it uses the specified date to generate the APK version code.
|
||||
// Otherwise, it generates the version code based on the current date.
|
||||
// See https://github.com/kiwix/kiwix-android/issues/4120 for more details.
|
||||
val currentDate = if (!System.getenv("RELEASE_DATE").isNullOrEmpty()) {
|
||||
LocalDate.parse(System.getenv("RELEASE_DATE"))
|
||||
} else {
|
||||
LocalDate.now()
|
||||
}
|
||||
// Calculate the number of days between the lastDate and today's date.
|
||||
// This gives us the total number of days since the last version code was set.
|
||||
val daysDifference = ChronoUnit.DAYS.between(lastDate, LocalDate.now()).toInt()
|
||||
val daysDifference = ChronoUnit.DAYS.between(lastDate, currentDate).toInt()
|
||||
|
||||
// Base version code. This is the version code of the last release uploaded to the Play Store.
|
||||
// We use this as the starting point for generating new version codes automatically.
|
||||
|
Loading…
x
Reference in New Issue
Block a user