Skip to content

Commit

Permalink
Added logs to check whether the environment variable is set, for debu…
Browse files Browse the repository at this point in the history
…gging purposes.

* Improved the ID of the "Retrieve date from git revision" job.
* Removed unnecessary conditions from the workflow.
  • Loading branch information
MohitMaliDeveloper committed Jan 6, 2025
1 parent befd7d3 commit 0ec90f0
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 26 deletions.
11 changes: 3 additions & 8 deletions .github/workflows/dummy_bundle_and_apk.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
11 changes: 3 additions & 8 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
11 changes: 3 additions & 8 deletions .github/workflows/testing_release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 6 additions & 2 deletions buildSrc/src/main/kotlin/VersionCodeGenerator.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit 0ec90f0

Please sign in to comment.