Added logs to check whether the environment variable is set, for debugging purposes.

* Improved the ID of the "Retrieve date from git revision" job.
* Removed unnecessary conditions from the workflow.
This commit is contained in:
MohitMaliFtechiz 2025-01-06 13:17:16 +05:30
parent befd7d389a
commit 0ec90f06b0
4 changed files with 15 additions and 26 deletions

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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.