Reorder workflow inputs #2
Workflow file for this run
This file contains 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: Android Release to Firebase App Distribution | ||
on: | ||
workflow_call: | ||
inputs: | ||
## Required Inputs | ||
VERSION_NAME: | ||
description: "Version name. Example: '1.X.X-snapshot'" | ||
required: true | ||
type: string | ||
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: true | ||
type: number | ||
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 | ||
APP_DISTRIBUTION_GROUPS: | ||
description: "Comma-separated list of app distribution group IDs" | ||
required: true | ||
type: string | ||
## Optional Inputs | ||
KMP_FLAVOR: | ||
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' | ||
TIMEOUT_MINUTES: | ||
description: "Job timeout in minutes" | ||
required: false | ||
type: number | ||
default: 30 | ||
JAVA_VERSION: | ||
description: "Java version to use" | ||
required: false | ||
type: string | ||
default: '17' | ||
JAVA_DISTRIBUTION: | ||
description: "Java distribution to use" | ||
required: false | ||
type: string | ||
default: 'zulu' | ||
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: | ||
java-version: ${{ inputs.JAVA_VERSION }} | ||
distribution: ${{ inputs.JAVA_DISTRIBUTION }} | ||
- 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 }}" |