Skip to content

Add android-cloud-release-firebaseAppDistribution.yml workflow #1

Add android-cloud-release-firebaseAppDistribution.yml workflow

Add android-cloud-release-firebaseAppDistribution.yml workflow #1

name: Android Release to Firebase App Distribution
on:
workflow_call:
inputs:
TIMEOUT_MINUTES:
description: "Job timeout in minutes"
required: false
type: number
default: 30
VERSION_NAME:
description: "Version name"
required: false
type: string
default: '1.X.X-snapshot'
BUILD_NUMBER_OFFSET:
description: "Build number offset. This number will be added to GITHUB_RUN_NUMBER and can be used to make corrections to build numbers."
required: false
type: number
default: 0
KMP_FLAVOR:

Check failure on line 21 in .github/workflows/android-cloud-release-firebaseAppDistribution.yml

View workflow run for this annotation

GitHub Actions / .github/workflows/android-cloud-release-firebaseAppDistribution.yml

Invalid workflow file

You have an error in your yaml syntax on line 21
description: "KMP Build flavor. This is optional and only required by KMP projects and can be ignored on pure Android projects".
required: false
type: string
default: 'test'
APP_DISTRIBUTION_GROUPS:
description: "Comma-separated list of app distribution group IDs"
required: true
type: string
TEST_GRADLE_TASKS:
description: "A Gradle task(s) for executing unit tests, for example `testReleaseUnitTest` or `testDevEnterpriseUnitTest`"
required: true
type: string
BUNDLE_GRADLE_TASK:
description: "A Gradle task for assembling app bundle, for example `bundleEnterprise`"
required: true
type: string
UPLOAD_GRADLE_TASK:
description: "A Gradle task for uploading APK, for example `appDistributionUploadEnterprise`"
required: true
type: string
SIGNING_KEYSTORE_PATH:
description: "Path to keystore for signing of universal APK. Example: `keystore/debug.jks' or 'androidApp/signing/debug.keystore'."
required: true
type: string
SIGNING_KEYSTORE_PASSWORD:
description: "Password to provided keystore"
required: true
type: string
SIGNING_KEY_ALIAS:
description: "Alias of the signing key in the provided keystore"
required: true
type: string
SIGNING_KEY_PASSWORD:
description: "Password to the key in the provided keystore"
required: true
type: string
secrets:
APP_DISTRIBUTION_SERVICE_ACCOUNT:
required: true
description: "Firebase App Distribution Service Account JSON key"
jobs:
build:
name: Enterprise Build
runs-on: [ ubuntu-latest ]
timeout-minutes: ${{ inputs.TIMEOUT_MINUTES }}
env:
FIREBASE_CREDENTIALS_FILE: firebase_credentials.json
BUNDLETOOL_URL: https://github.com/google/bundletool/releases/download/1.17.2/bundletool-all-1.17.2.jar
EXCLUDE_AAB_FILTER: .*intermediate
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Java
uses: actions/setup-java@v4
with:
distribution: 'zulu'
java-version: '17'
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v4
- name: Prepare Environment
run: |
echo "BUILD_NUMBER=$((GITHUB_RUN_NUMBER + ${{ inputs.BUILD_NUMBER_OFFSET}} ))" >> $GITHUB_ENV
echo "VERSION_NAME=${{ inputs.VERSION_NAME }}" >> $GITHUB_ENV
echo "KMP_FLAVOR=${{ inputs.KMP_FLAVOR }}" >> $GITHUB_ENV
- name: Run Unit tests
shell: bash
run: ./gradlew --continue ${{ inputs.TEST_GRADLE_TASKS }}
- name: Generate Artifacts (AAB and APK)
id: artifacts
shell: bash
run: |
./gradlew ${{ inputs.BUNDLE_GRADLE_TASK }} -P buildkonfig.flavor=$KMP_FLAVOR
BUNDLE_FILE=$(find . -name '*.aab' | grep -v '.*intermediate')
wget -O bundletool.jar ${{ env.BUNDLETOOL_URL }}
java -jar bundletool.jar build-apks \
--bundle $BUNDLE_FILE \
--output universal.apks \
--mode universal \
--ks ${{ inputs.SIGNING_KEYSTORE_PATH }}
--ks-pass pass:${{ inputs.SIGNING_KEYSTORE_PASSWORD }} \
--ks-key-alias ${{ inputs.SIGNING_KEY_ALIAS }}
--key-pass pass:${{ inputs.SIGNING_KEY_PASSWORD }}
unzip universal.apks -d universal_apk
UNIVERSAL_APK_FILE=$(find universal_apk/ -name '*.apk')
echo "bundle_file=$BUNDLE_FILE" >> $GITHUB_OUTPUT
echo "universal_apk_file=$UNIVERSAL_APK_FILE" >> $GITHUB_OUTPUT
- name: Upload to Firebase App Distribution
shell: bash
run: |
echo '${{ secrets.APP_DISTRIBUTION_SERVICE_ACCOUNT }}' > $FIREBASE_CREDENTIALS_FILE
./gradlew ${{ inputs.UPLOAD_GRADLE_TASK }} \
--serviceCredentialsFile="$FIREBASE_CREDENTIALS_FILE" \
--groups="${{ inputs.APP_DISTRIBUTION_GROUPS }}"
--artifactType="APK" \
--artifactPath="${{ steps.artifacts.outputs.universal_apk_file }}"