Skip to content

Commit

Permalink
chore: build primary sample app
Browse files Browse the repository at this point in the history
  • Loading branch information
mrehan27 committed Jan 10, 2025
1 parent deda228 commit e514e48
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 18 deletions.
25 changes: 25 additions & 0 deletions .github/workflows/build-sample-apps.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,29 @@ jobs:
- uses: actions/checkout@v4

# Install CLI tools, Ruby, and Ruby dependencies for Fastlane

- 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 }}" == "APN" ]] && 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: Install CLI tools used in CI script
shell: bash
Expand Down Expand Up @@ -173,6 +196,7 @@ jobs:
with:
subdirectory: Apps/${{ matrix.sample-app }}
lane: 'android build'
options: '{"distribution_groups": "${{ env.firebase_distribution_groups }}"}'
env:
FIREBASE_APP_DISTRIBUTION_SERVICE_ACCOUNT_CREDS_B64: ${{ secrets.FIREBASE_APP_DISTRIBUTION_SERVICE_ACCOUNT_CREDS_B64 }}
continue-on-error: true # continue to build iOS app even if Android build fails
Expand All @@ -190,6 +214,7 @@ jobs:
with:
subdirectory: Apps/${{ matrix.sample-app }}
lane: "ios build"
options: '{"distribution_groups": "${{ env.firebase_distribution_groups }}"}'
env:
GOOGLE_CLOUD_MATCH_READONLY_SERVICE_ACCOUNT_B64: ${{ secrets.GOOGLE_CLOUD_MATCH_READONLY_SERVICE_ACCOUNT_B64 }}
FIREBASE_APP_DISTRIBUTION_SERVICE_ACCOUNT_CREDS_B64: ${{ secrets.FIREBASE_APP_DISTRIBUTION_SERVICE_ACCOUNT_CREDS_B64 }}
Expand Down
27 changes: 9 additions & 18 deletions Apps/fastlane/helpers/build_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
apk_path: distribution_apk_path,
app: firebase_app_id, # Firebase app id is required. Get it from google-services.json file
service_credentials_file: service_credentials_file_path,
groups: get_build_test_groups(),
groups: get_build_test_groups(distribution_groups: values[:distribution_groups]),
release_notes: get_build_notes()
)
end
Expand Down Expand Up @@ -83,7 +83,7 @@

firebase_app_distribution(
service_credentials_file: service_credentials_file_path,
groups: get_build_test_groups(),
groups: get_build_test_groups(distribution_groups: arguments[:distribution_groups]),
release_notes: get_build_notes()
)
end
Expand Down Expand Up @@ -123,22 +123,13 @@
build_notes # return value
end

lane :get_build_test_groups do
test_groups = ['all-builds'] # send all builds to group 'all-builds'. Therefore, set it here and we will not remove it.
test_groups.append("feature-branch") # Feature branch will be used when a PR is merged into a feature branch. We will need to add a check for this.
github = GitHub.new()

# To avoid giving potentially unstable builds of our sample apps to certain members of the organization, we only send builds to "stable" group uncertain certain situations.
# If a commit is merged into main, it's considered stable because we deploy to production on merges to main.
if github.is_commit_pushed && github.push_branch == "main"
test_groups.append("stable-builds")
test_groups.append("next") # Next group will depricate the 'stable` builds group'.
test_groups.append("public") # Temp send to public group until we actually build from the deployed SDK.
end

test_groups = test_groups.join(", ")
lane :get_build_test_groups do |arguments|
# Firebase App Distribution expects a comma separated string of test group names.
# If no groups are passed in, then set test groups to an empty string.
test_groups = arguments[:distribution_groups] || ""

UI.important("Test group names that will be added to this build: #{test_groups}")

test_groups # return value
end
test_groups # return value
end

0 comments on commit e514e48

Please sign in to comment.