Skip to content

Commit fa0a7f4

Browse files
We refactored our dummy_bundle.yml workflow to generate the dummy bundle and APKs based on a specified date, using a new tag format dummy_bundle_and_apk_v*, where * is replaced by the date in YYYY_MM_DD. This date is extracted and set as an environment variable to generate the app bundle and APK for that date, defaulting to the current date if no date is provided.
* Now, our `dummy_bundle.yml` will generate both the app bundle and APKs, so if we need the APK for a specified date, we can easily retrieve it. * Added comments in both workflows to understand the flow of the workflows.
1 parent 887d543 commit fa0a7f4

File tree

3 files changed

+83
-51
lines changed

3 files changed

+83
-51
lines changed

.github/workflows/dummy_bundle.yml

Lines changed: 0 additions & 50 deletions
This file was deleted.
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
name: Generate dummy bundle and APK
2+
3+
# This workflow will trigger when the 'dummy_bundle_and_apk' or 'dummy_bundle_and_apk_v*' tag is pushed.
4+
# In 'dummy_bundle_and_apk_v*', '*' is a dynamic date pushed in the tag.
5+
# The date format should be YYYY-MM-DD (e.g., 2024-12-18).
6+
on:
7+
push:
8+
tags:
9+
- 'dummy_bundle_and_apk' # dummy_bundle_and_apk Tag.
10+
- 'dummy_bundle_and_apk_v*' # Trigger for generating dummy bundle and APKs with dynamic date.
11+
12+
jobs:
13+
publish_dummy_bundle_and_apk:
14+
runs-on: ubuntu-22.04
15+
16+
steps:
17+
- uses: actions/checkout@v4
18+
19+
- name: Set up JDK 17
20+
uses: actions/setup-java@v4
21+
with:
22+
java-version: 17
23+
distribution: temurin
24+
25+
- name: Preparing signing material
26+
env:
27+
KEYSTORE: ${{ secrets.keystore }}
28+
run: |
29+
echo "$KEYSTORE" | base64 -d > kiwix-android.keystore
30+
31+
- name: Retrieve date from TAG
32+
id: extract_date
33+
run: |
34+
# Check if the tag matches the pattern 'dummy_bundle_and_apk_vYYYY-MM-DD'.
35+
# If the date is found in the tag, it will be extracted and set as the RELEASE_DATE.
36+
# If no date is found or the tag does not match, an empty string will be set for RELEASE_DATE,
37+
# and Android will generate the APK and app bundle for the current date.
38+
if [[ "${GITHUB_REF}" =~ dummy_bundle_and_apk_v([0-9]{4}-[0-9]{2}-[0-9]{2}) ]]; then
39+
RELEASE_DATE="${BASH_REMATCH[1]}"
40+
else
41+
RELEASE_DATE=""
42+
fi
43+
echo "KIWIX_ANDROID_RELEASE_DATE=$RELEASE_DATE" >> $GITHUB_ENV
44+
45+
- name: Generate dummy Bundle and APKs
46+
env:
47+
KEY_ALIAS: ${{ secrets.KEY_ALIAS }}
48+
KEY_PASSWORD: ${{ secrets.KEY_PASSWORD }}
49+
KEY_STORE_PASSWORD: ${{ secrets.KEY_STORE_PASSWORD }}
50+
KIWIX_ANDROID_RELEASE_DATE: ${{ env.KIWIX_ANDROID_RELEASE_DATE }}
51+
run: |
52+
./gradlew bundlePlayStore assembleRelease --scan
53+
54+
55+
- name: Get Bundle and APKs name and path
56+
id: get-bundle-and-apk-paths
57+
run: |
58+
BUNDLE_PATH="app/build/outputs/bundle/playStore/kiwix-playStore.aab"
59+
BUNDLE_NAME="PlayStoreDummyBundle.aab"
60+
echo "bundle_path=$BUNDLE_PATH" >> $GITHUB_ENV
61+
echo "bundle_name=$BUNDLE_NAME" >> $GITHUB_ENV
62+
APK_DIR="app/build/outputs/apk/release/"
63+
echo "apk_dir=$APK_DIR" >> $GITHUB_ENV
64+
65+
- name: Upload Bundle as an artifact
66+
uses: actions/upload-artifact@v4
67+
with:
68+
name: ${{ env.bundle_name }}
69+
path: ${{ env.bundle_path }}
70+
71+
- name: Upload All Release APKs as artifacts
72+
uses: actions/upload-artifact@v4
73+
with:
74+
name: ReleaseApks
75+
path: ${{ env.apk_dir }}*.apk
76+

.github/workflows/testing_release.yml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
name: Publish App to Play Store
22

3-
# Trigger the workflow on a schedule (every Monday at 12:00 UTC)
3+
# This workflow is triggered on a schedule or when specific tags are pushed.
4+
# It runs every Monday at 12:00 UTC and also when the 'internal_testing' or 'internal_testing_v*' tag is pushed.
5+
# In 'internal_testing_v*', '*' represents a dynamic date (e.g., 2024-12-18).
46
on:
57
schedule:
68
- cron: '0 12 * * 1' # Runs every Monday at 12:00
@@ -33,6 +35,10 @@ jobs:
3335
- name: Retrieve date from TAG
3436
id: extract_date
3537
run: |
38+
# Check if the tag matches the pattern 'internal_testing_vYYYY-MM-DD'.
39+
# If the date is found in the tag, it will be extracted and set as the RELEASE_DATE.
40+
# If no date is found or the tag does not match, an empty string will be set for RELEASE_DATE.
41+
# Android will use the current date for the APK generation.
3642
if [[ "${GITHUB_REF}" =~ internal_testing_v([0-9]{4}-[0-9]{2}-[0-9]{2}) ]]; then
3743
RELEASE_DATE="${BASH_REMATCH[1]}"
3844
else

0 commit comments

Comments
 (0)