diff --git a/.github/workflows/dummy_bundle_and_apk.yml b/.github/workflows/dummy_bundle_and_apk.yml index 4a43c47f8a..00736d16c3 100644 --- a/.github/workflows/dummy_bundle_and_apk.yml +++ b/.github/workflows/dummy_bundle_and_apk.yml @@ -26,15 +26,10 @@ jobs: echo "$KEYSTORE" | base64 -d > kiwix-android.keystore - name: Retrieve date from git revision - id: git_date + id: git_head_revision_date run: | - DATE=$(git log -1 --format=%cd --date=format:%Y-%m-%d || echo "NoCommits") - if [ "$DATE" = "NoCommits" ]; then - RELEASE_DATE="" - else - RELEASE_DATE="$DATE" - fi - echo "KIWIX_ANDROID_RELEASE_DATE=$RELEASE_DATE" >> $GITHUB_ENV + DATE=$(git log -1 --format=%cd --date=format:%Y-%m-%d) + echo "KIWIX_ANDROID_RELEASE_DATE=$DATE" >> $GITHUB_ENV shell: bash - name: Generate dummy Bundle and APKs diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index f540ce8d2c..342e9b7dd2 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -22,15 +22,10 @@ jobs: run: echo "TAG=$(echo ${GITHUB_REF:10})" >> $GITHUB_ENV - name: Retrieve date from git revision - id: git_date + id: git_head_revision_date run: | - DATE=$(git log -1 --format=%cd --date=format:%Y-%m-%d || echo "NoCommits") - if [ "$DATE" = "NoCommits" ]; then - RELEASE_DATE="" - else - RELEASE_DATE="$DATE" - fi - echo "KIWIX_ANDROID_RELEASE_DATE=$RELEASE_DATE" >> $GITHUB_ENV + DATE=$(git log -1 --format=%cd --date=format:%Y-%m-%d) + echo "KIWIX_ANDROID_RELEASE_DATE=$DATE" >> $GITHUB_ENV shell: bash - name: Retrieve secrets to files diff --git a/.github/workflows/testing_release.yml b/.github/workflows/testing_release.yml index 93792a106c..d9a8362cb4 100644 --- a/.github/workflows/testing_release.yml +++ b/.github/workflows/testing_release.yml @@ -31,15 +31,10 @@ jobs: echo "$PLAYSTORE_JSON" > playstore.json - name: Retrieve date from git revision - id: git_date + id: git_head_revision_date run: | - DATE=$(git log -1 --format=%cd --date=format:%Y-%m-%d || echo "NoCommits") - if [ "$DATE" = "NoCommits" ]; then - RELEASE_DATE="" - else - RELEASE_DATE="$DATE" - fi - echo "KIWIX_ANDROID_RELEASE_DATE=$RELEASE_DATE" >> $GITHUB_ENV + DATE=$(git log -1 --format=%cd --date=format:%Y-%m-%d) + echo "KIWIX_ANDROID_RELEASE_DATE=$DATE" >> $GITHUB_ENV shell: bash - name: Publish bundle in internal testing on Google Play diff --git a/buildSrc/src/main/kotlin/VersionCodeGenerator.kt b/buildSrc/src/main/kotlin/VersionCodeGenerator.kt index c962a9d47c..a61cf3e1ed 100644 --- a/buildSrc/src/main/kotlin/VersionCodeGenerator.kt +++ b/buildSrc/src/main/kotlin/VersionCodeGenerator.kt @@ -37,9 +37,13 @@ fun String.getVersionCode(): Int { // 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("KIWIX_ANDROID_RELEASE_DATE").isNullOrEmpty()) { - LocalDate.parse(System.getenv("KIWIX_ANDROID_RELEASE_DATE")) + LocalDate.parse(System.getenv("KIWIX_ANDROID_RELEASE_DATE")).also { + println("Environment variable found. Using date: $it for version code generation.") + } } else { - LocalDate.now() + LocalDate.now().also { + println("No environment variable found. Using current date: $it for version code generation.") + } } // Calculate the number of days between the LAST_DATE and today's date. // This gives us the total number of days since the last version code was set.