From 7b87c884039012a402ce82209f600870b5916e89 Mon Sep 17 00:00:00 2001 From: Rehan Date: Fri, 10 Jan 2025 15:35:11 +0500 Subject: [PATCH] chore: build primary sample app --- .../workflows/reusable_build_sample_apps.yml | 44 ++++++++++++++++++- samples/fastlane/Fastfile | 4 +- 2 files changed, 45 insertions(+), 3 deletions(-) diff --git a/.github/workflows/reusable_build_sample_apps.yml b/.github/workflows/reusable_build_sample_apps.yml index d6365daf..cb3f5e6f 100644 --- a/.github/workflows/reusable_build_sample_apps.yml +++ b/.github/workflows/reusable_build_sample_apps.yml @@ -37,6 +37,29 @@ jobs: with: fetch-depth: 0 # Workaround for bug https://github.com/actions/checkout/issues/1471 + - name: Set Default Firebase Distribution Groups + run: | + # Define all the possible distribution groups + ALL_BUILDS_GROUP="all-builds" + FEATURE_BUILDS_GROUP="feature-branch" + STABLE_BUILDS_GROUP="next" + + # Initialize with the default distribution group + distribution_groups=("$ALL_BUILDS_GROUP") + + # Determine current app type and Git context + is_primary_app=$([[ "${{ matrix.sample-app }}" == "java_layout" ]] && echo "true" || echo "false") + current_branch="${GITHUB_REF}" + + # Append distribution groups based on branch and context if the app is primary + if [[ "$is_primary_app" == "true" ]]; then + [[ "$current_branch" == "refs/heads/feature/"* ]] && distribution_groups+=("$FEATURE_BUILDS_GROUP") + [[ "$current_branch" == "refs/heads/main" ]] && distribution_groups+=("$STABLE_BUILDS_GROUP") + fi + + # Export the groups as an environment variable + echo "firebase_distribution_groups=$(IFS=','; echo "${distribution_groups[*]}")" >> $GITHUB_ENV + - name: Get latest SDK version if: ${{ inputs.use_latest_sdk_version == true }} id: latest-sdk-version-step @@ -74,13 +97,32 @@ jobs: - name: Dump GitHub Action metadata because Fastlane uses it. Viewing it here helps debug JSON parsing code in Firebase. run: cat $GITHUB_EVENT_PATH + - name: Prepare Fastlane Build Arguments + run: | + if [ "${{ inputs.use_latest_sdk_version }}" = "true" ]; then + sdk_version="\"sdk_version\":\"${{ steps.latest-sdk-version-step.outputs.LATEST_TAG }}\"" + else + sdk_version="" + fi + + distribution_groups="\"distribution_groups\":\"${{ env.firebase_distribution_groups }}\"" + + # Construct the fastlane-build-args JSON + if [ -n "$sdk_version" ]; then + fastlane_build_args="{${sdk_version},${distribution_groups}}" + else + fastlane_build_args="{${distribution_groups}}" + fi + + echo "fastlane_build_args=$fastlane_build_args" >> $GITHUB_ENV + - name: Deploy build via Fastlane if: ${{ ! (inputs.use_latest_sdk_version == true && matrix.sample-app == 'kotlin_compose') }} uses: maierj/fastlane-action@v3.1.0 with: lane: ${{ inputs.use_latest_sdk_version == true && 'android build_sample_app_for_sdk_release' || 'android build' }} subdirectory: "samples/${{ matrix.sample-app }}" - options: ${{ inputs.use_latest_sdk_version == true && format('{{"sdk_version":"{0}"}}', steps.latest-sdk-version-step.outputs.LATEST_TAG) || '' }} + options: ${{ env.fastlane_build_args }} env: ANDROID_SIGNING_ALIAS: ${{ secrets.ANDROID_SIGNING_ALIAS }} ANDROID_SIGNING_KEY_PASSWORD: ${{ secrets.ANDROID_SIGNING_KEY_PASSWORD }} diff --git a/samples/fastlane/Fastfile b/samples/fastlane/Fastfile index c7eb36d0..92ac2a43 100644 --- a/samples/fastlane/Fastfile +++ b/samples/fastlane/Fastfile @@ -1,7 +1,7 @@ # There are some re-usable functions in other Fastfile files in the org we can re-use. import_from_git( url: "https://github.com/customerio/customerio-ios.git", - branch: "main", + branch: "rehan/mbl-710-ci-updates", path: "Apps/fastlane/Fastfile" ) @@ -65,7 +65,7 @@ platform :android do name_of_sample_app_module = File.basename(path_to_root_directory_sample_app) # just get the name of the directory I am in now. `samples/N` new_app_version = get_new_app_version().gsub("/", ".") - test_groups = get_build_test_groups() + test_groups = get_build_test_groups(distribution_groups: values[:distribution_groups]) app_package_name = CredentialsManager::AppfileConfig.try_fetch_value(:package_name) # get package_name from Appfile build_sample_app(