Wikimed FR 2025-11 #82
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: CD | |
| on: | |
| release: | |
| types: [published] | |
| branches: | |
| - main | |
| jobs: | |
| publish: | |
| runs-on: ubuntu-22.04 | |
| steps: | |
| - name: Retrieving custom app configuration | |
| uses: actions/checkout@v4 | |
| - name: Set up JDK 17 | |
| uses: actions/setup-java@v4 | |
| with: | |
| java-version: 17 | |
| distribution: temurin | |
| - name: Set tag variable | |
| run: echo "TAG=$(echo ${GITHUB_REF:10})" >> $GITHUB_ENV | |
| - name: Install jq | |
| run: sudo apt-get install -y jq | |
| - name: Read revision ID from info.json | |
| run: | | |
| cd ${TAG} | |
| rev_id=$(jq -r '."kiwix-android_revision" // empty' info.json) | |
| if [ -z "$rev_id" ] || [ "$rev_id" = "latest" ]; then | |
| echo "REV_ID=" >> $GITHUB_ENV | |
| else | |
| echo "REV_ID=$rev_id" >> $GITHUB_ENV | |
| fi | |
| - name: Retrieving Kiwix Android source code | |
| run: | | |
| if [ -z "${{ env.REV_ID }}" ]; then | |
| echo "Cloning latest commit from main branch" | |
| git clone --depth=1 --single-branch --branch main https://github.com/kiwix/kiwix-android.git | |
| else | |
| echo "Cloning specific commit: ${{ env.REV_ID }}" | |
| git clone https://github.com/kiwix/kiwix-android.git | |
| cd kiwix-android | |
| git checkout ${{ env.REV_ID }} | |
| cd .. | |
| fi | |
| - name: Copying custom app configuration into Kiwix Android code base | |
| run: ./copy_files_to_kiwix_android.sh | |
| - name: Set non-kiwix organization tag | |
| run: | | |
| non_kiwix_organization_tag="PLAYSTORE_JSON_${TAG^^}" | |
| echo "NON_KIWIX_ORGANIZATION_TAG=${non_kiwix_organization_tag}" >> $GITHUB_ENV | |
| - name: Preparing signing material | |
| env: | |
| keystore: ${{ secrets.keystore }} | |
| playstore_json: ${{ secrets.PLAYSTORE_JSON }} | |
| non_kiwix_organization_json: ${{ secrets[env.NON_KIWIX_ORGANIZATION_TAG] }} | |
| run: | | |
| echo "$keystore" | base64 -d > kiwix-android/kiwix-android.keystore | |
| if [ -n "$non_kiwix_organization_json" ]; then | |
| echo "$non_kiwix_organization_json" > kiwix-android/playstore.json | |
| else | |
| echo "$playstore_json" > kiwix-android/playstore.json | |
| fi | |
| - name: Should upload Bundle | |
| run: | | |
| cd ${TAG} | |
| should_publish_bundle=$(jq -r '.upload_bundle // empty' info.json) | |
| if [ "$should_publish_bundle" == 'true' ]; then | |
| echo "should_publish_bundle=true" >> $GITHUB_ENV | |
| else | |
| echo "APK_BUILD=true" >> $GITHUB_ENV | |
| echo "should_publish_bundle=false" >> $GITHUB_ENV | |
| fi | |
| - name: Publishing app to Google Play | |
| env: | |
| KEY_ALIAS: ${{ secrets.KEY_ALIAS }} | |
| KEY_PASSWORD: ${{ secrets.KEY_PASSWORD }} | |
| KEY_STORE_PASSWORD: ${{ secrets.KEY_STORE_PASSWORD }} | |
| DWDS_HTTP_BASIC_ACCESS_AUTHENTICATION: ${{ secrets.DWDS_HTTP_BASIC_ACCESS_AUTHENTICATION }} | |
| run: | | |
| cd kiwix-android | |
| if [ "${{ env.should_publish_bundle }}" == 'true' ]; then | |
| eval "./gradlew publish${TAG^}ReleaseBundleWithPlayAssetDelivery" | |
| else | |
| eval "./gradlew publish${TAG^}ReleaseApkWithExpansionFile" | |
| fi | |
| publish_dummy_bundle: | |
| runs-on: ubuntu-22.04 | |
| steps: | |
| - name: Retrieving custom app configuration | |
| uses: actions/checkout@v4 | |
| - name: Set up JDK 17 | |
| uses: actions/setup-java@v4 | |
| with: | |
| java-version: 17 | |
| distribution: temurin | |
| - name: Set tag variable | |
| run: echo "TAG=$(echo ${GITHUB_REF:10})" >> $GITHUB_ENV | |
| - name: Install jq | |
| run: sudo apt-get install -y jq | |
| - name: Read revision ID from info.json | |
| run: | | |
| cd ${TAG} | |
| rev_id=$(jq -r '."kiwix-android_revision" // empty' info.json) | |
| if [ -z "$rev_id" ] || [ "$rev_id" = "latest" ]; then | |
| echo "REV_ID=" >> $GITHUB_ENV | |
| else | |
| echo "REV_ID=$rev_id" >> $GITHUB_ENV | |
| fi | |
| - name: Retrieving Kiwix Android source code | |
| run: | | |
| if [ -z "${{ env.REV_ID }}" ]; then | |
| echo "Cloning latest commit from main branch" | |
| git clone --depth=1 --single-branch --branch main https://github.com/kiwix/kiwix-android.git | |
| else | |
| echo "Cloning specific commit: ${{ env.REV_ID }}" | |
| git clone https://github.com/kiwix/kiwix-android.git | |
| cd kiwix-android | |
| git checkout ${{ env.REV_ID }} | |
| cd .. | |
| fi | |
| - name: Copying custom app configuration into Kiwix Android code base | |
| run: ./copy_files_to_kiwix_android.sh | |
| - name: Should upload dummy Bundle | |
| run: | | |
| cd ${TAG} | |
| should_publish=$(jq -r '.new // empty' info.json) | |
| if [ "$should_publish" == 'true' ]; then | |
| echo "should_publish=true" >> $GITHUB_ENV | |
| else | |
| echo "should_publish=false" >> $GITHUB_ENV | |
| fi | |
| - name: Preparing signing material | |
| if: env.should_publish == 'true' | |
| env: | |
| keystore: ${{ secrets.keystore }} | |
| run: | | |
| echo "$keystore" | base64 -d > kiwix-android/kiwix-android.keystore | |
| - name: Generate dummy Bundle | |
| if: env.should_publish == 'true' | |
| env: | |
| KEY_ALIAS: ${{ secrets.KEY_ALIAS }} | |
| KEY_PASSWORD: ${{ secrets.KEY_PASSWORD }} | |
| KEY_STORE_PASSWORD: ${{ secrets.KEY_STORE_PASSWORD }} | |
| DWDS_HTTP_BASIC_ACCESS_AUTHENTICATION: ${{ secrets.DWDS_HTTP_BASIC_ACCESS_AUTHENTICATION }} | |
| run: | | |
| cd kiwix-android | |
| eval "./gradlew bundle${TAG^}Release" | |
| - name: Get Bundle name and path | |
| if: env.should_publish == 'true' | |
| id: bundle-path | |
| run: | | |
| BUNDLE_PATH="kiwix-android/custom/build/outputs/bundle/${TAG}Release/*${TAG}*.aab" | |
| BUNDLE_NAME="${TAG^}DummyBundle.aab" | |
| echo "bundle_path=$BUNDLE_PATH" >> $GITHUB_ENV | |
| echo "bundle_name=$BUNDLE_NAME" >> $GITHUB_ENV | |
| - name: Upload Bundle as an artifact | |
| if: env.should_publish == 'true' | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: ${{ env.bundle_name }} | |
| path: ${{ env.bundle_path }} | |