Skip to content

Commit 74b348d

Browse files
Add and update workflows for release and non-release SDK sample apps
1 parent 2a071b8 commit 74b348d

File tree

3 files changed

+334
-164
lines changed

3 files changed

+334
-164
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
name: Publish test apps for SDK release
2+
3+
on:
4+
workflow_dispatch:
5+
pull_request:
6+
7+
jobs:
8+
build-sample-apps:
9+
uses: ./.github/workflows/reusable_build_sample_apps.yml
10+
with:
11+
use_latest_sdk_version: true
12+
secrets: inherit

.github/workflows/build-sample-apps.yml

+17-164
Original file line numberDiff line numberDiff line change
@@ -45,186 +45,39 @@ jobs:
4545
${{ steps.build.outputs.build-log }}
4646
edit-mode: replace # replace the existing comment with new content since we are creating new builds
4747

48-
build-ios-sample-apps:
48+
49+
build-sample-apps:
4950
if: ${{ always() }} # do not skip running this step if update-pr-comment does not run
5051
needs: [ update-pr-comment ] # wait for PR comment to be created saying new builds are being made.
52+
uses: ./.github/workflows/reusable_build_sample_apps.yml
53+
with:
54+
use_latest_sdk_version: false
55+
secrets: inherit
56+
57+
update-pr-comment-after-apps-built:
58+
if: always() && ${{ github.event_name == 'pull_request' }}
59+
needs: [ update-pr-comment, build-sample-apps ] # wait for PR comment to be created saying new builds are being made.
60+
runs-on: ubuntu-latest
5161
permissions:
52-
pull-requests: write # comment on pull request with build information
53-
strategy:
54-
fail-fast: false # if one sample app fails to build, let the other sample apps continue to build and not cancel them.
55-
matrix: # Use a matrix allowing us to build multiple apps in parallel. Just add an entry to the matrix and it will build!
56-
sample-app:
57-
# List all sample apps you want to have compiled.
58-
# List item is name of directory inside of "apps" directory for the corresponding app to compile.
59-
- name: "amiapp_flutter"
60-
cio-workspace-name: "Mobile: Flutter"
61-
defaults:
62-
run:
63-
working-directory: apps/${{ matrix.sample-app.name }}
64-
runs-on: macos-14
65-
name: Building sample app ${{ matrix.sample-app.name }}
66-
steps:
67-
- uses: actions/checkout@v4
68-
69-
- name: Set Default Firebase Distribution Groups
70-
shell: bash
71-
env:
72-
# Distribution group constants
73-
ALL_BUILDS_GROUP: all-builds
74-
FEATURE_BUILDS_GROUP: feature-branch
75-
NEXT_BUILDS_GROUP: next
76-
PUBLIC_BUILDS_GROUP: public
77-
# Input variables
78-
CURRENT_BRANCH: ${{ github.ref }}
79-
run: |
80-
# Initialize with the default distribution group
81-
distribution_groups=("$ALL_BUILDS_GROUP")
82-
83-
# Append distribution groups based on branch and context
84-
[[ "$CURRENT_BRANCH" == "refs/heads/feature/"* ]] && distribution_groups+=("$FEATURE_BUILDS_GROUP")
85-
[[ "$CURRENT_BRANCH" == "refs/heads/main" ]] && distribution_groups+=("$NEXT_BUILDS_GROUP")
86-
[[ "$CURRENT_BRANCH" == "refs/heads/main" ]] && distribution_groups+=("$PUBLIC_BUILDS_GROUP")
87-
88-
# Export the groups as an environment variable
89-
echo "firebase_distribution_groups=$(IFS=','; echo "${distribution_groups[*]}")" >> $GITHUB_ENV
90-
91-
# Install CLI tools, Ruby, and Ruby dependencies for Fastlane
92-
93-
- name: Install CLI tools used in CI script
94-
shell: bash
95-
run: |
96-
brew install sd # used in CI script as an easier to use sed CLI. Replaces text in files.
97-
brew install xcbeautify # used by fastlane for output
98-
99-
- name: Install Ruby
100-
uses: ruby/setup-ruby@v1
101-
with:
102-
bundler-cache: true # cache tools to make builds faster in future
103-
working-directory: apps/${{ matrix.sample-app.name }}
104-
105-
# Update version numbers and workspace credentials before building the app
106-
107-
- name: Generate New Version
108-
uses: maierj/fastlane-action@v3.1.0
109-
with:
110-
subdirectory: apps/${{ matrix.sample-app.name }}
111-
lane: "generate_new_version"
112-
options: '{"branch_name":"${{ github.ref_name }}", "pull_request_number":"${{ github.event.pull_request.number }}"}'
113-
114-
- name: Update Flutter SDK Version
115-
uses: maierj/fastlane-action@v3.1.0
116-
with:
117-
subdirectory: apps/${{ matrix.sample-app.name }}
118-
lane: "update_flutter_sdk_version"
119-
env:
120-
SDK_VERSION_NAME: ${{ env.SDK_VERSION_NAME }}
121-
APP_VERSION_NAME: ${{ env.APP_VERSION_NAME }}
122-
APP_VERSION_CODE: ${{ env.APP_VERSION_CODE }}
123-
124-
- name: Update Sample App Version
125-
uses: maierj/fastlane-action@v3.1.0
126-
with:
127-
subdirectory: apps/${{ matrix.sample-app.name }}
128-
lane: "update_flutter_app_version"
129-
env:
130-
SDK_VERSION_NAME: ${{ env.SDK_VERSION_NAME }}
131-
APP_VERSION_NAME: ${{ env.APP_VERSION_NAME }}
132-
APP_VERSION_CODE: ${{ env.APP_VERSION_CODE }}
133-
134-
- name: Setup workspace credentials in flutter environment files
135-
env:
136-
BRANCH_NAME: ${{ github.head_ref || github.ref_name }}
137-
COMMIT_HASH: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.sha }}
138-
run: |
139-
env_file=".env"
140-
touch "$env_file"
141-
echo "BUILD_TIMESTAMP=$(date +%s)" >> "$env_file"
142-
echo "CDP_API_KEY=${{ secrets[format('CUSTOMERIO_{0}_WORKSPACE_CDP_API_KEY', matrix.sample-app.name)] }}" >> "$env_file"
143-
echo "SITE_ID=${{ secrets[format('CUSTOMERIO_{0}_WORKSPACE_SITE_ID', matrix.sample-app.name)] }}" >> "$env_file"
144-
echo "WORKSPACE_NAME=${{ matrix.sample-app.cio-workspace-name }}" >> "$env_file"
145-
echo "BRANCH_NAME=$BRANCH_NAME" >> "$env_file"
146-
echo "COMMIT_HASH=${COMMIT_HASH:0:7}" >> "$env_file"
147-
echo "COMMITS_AHEAD_COUNT=$(git rev-list $(git describe --tags --abbrev=0)..HEAD --count)" >> "$env_file"
148-
# Add `SDK_VERSION` to env_file here if it's a public build
149-
150-
- name: Setup workspace credentials in iOS environment files
151-
run: |
152-
cp "ios/Env.swift.example" "ios/Env.swift"
153-
sd 'cdpApiKey: String = ".*"' "cdpApiKey: String = \"${{ secrets[format('CUSTOMERIO_{0}_WORKSPACE_CDP_API_KEY', matrix.sample-app.name)] }}\"" "ios/Env.swift"
154-
155-
# Make sure to fetch dependencies only after updating the version numbers and workspace credentials
156-
157-
- name: Setup flutter environment and install dependencies
158-
uses: ./.github/actions/setup-flutter
159-
160-
- name: Install flutter dependencies for sample app
161-
run: flutter pub get
162-
163-
- name: Setup Android environment for sample app
164-
uses: customerio/customerio-android/.github/actions/setup-android@main
165-
166-
- name: Build and upload Android app via Fastlane
167-
id: android_build
168-
uses: maierj/fastlane-action@v3.1.0
169-
with:
170-
subdirectory: apps/${{ matrix.sample-app.name }}
171-
lane: 'android build'
172-
options: '{"distribution_groups": "${{ env.firebase_distribution_groups }}"}'
173-
env:
174-
FIREBASE_APP_DISTRIBUTION_SERVICE_ACCOUNT_CREDS_B64: ${{ secrets.FIREBASE_APP_DISTRIBUTION_SERVICE_ACCOUNT_CREDS_B64 }}
175-
continue-on-error: true # continue to build iOS app even if Android build fails
176-
177-
- name: Setup iOS environment for sample app
178-
uses: customerio/customerio-ios/.github/actions/setup-ios@main
179-
with:
180-
xcode-version: ${{ env.XCODE_VERSION }}
181-
182-
- name: Cache CocoaPods downloaded dependencies for faster builds in the future
183-
uses: actions/cache@v4
184-
with:
185-
path: Pods
186-
key: ${{ runner.os }}-${{ matrix.sample-app.name }}-Pods-${{ github.ref }}
187-
restore-keys: |
188-
${{ runner.os }}-${{ matrix.sample-app.name }}-Pods
189-
190-
- name: pod install
191-
run: pod install --project-directory=ios
192-
193-
- name: Build and upload iOS app via Fastlane
194-
id: ios_build
195-
uses: maierj/fastlane-action@v3.1.0
196-
with:
197-
subdirectory: apps/${{ matrix.sample-app.name }}
198-
lane: "ios build"
199-
options: '{"distribution_groups": "${{ env.firebase_distribution_groups }}"}'
200-
env:
201-
GOOGLE_CLOUD_MATCH_READONLY_SERVICE_ACCOUNT_B64: ${{ secrets.GOOGLE_CLOUD_MATCH_READONLY_SERVICE_ACCOUNT_B64 }}
202-
FIREBASE_APP_DISTRIBUTION_SERVICE_ACCOUNT_CREDS_B64: ${{ secrets.FIREBASE_APP_DISTRIBUTION_SERVICE_ACCOUNT_CREDS_B64 }}
203-
204-
- name: Check build statuses and mark failure
205-
run: |
206-
if [ "${{ steps.android_build.outcome }}" != "success" ] || [ "${{ steps.ios_build.outcome }}" != "success" ]; then
207-
echo "One or more builds failed."
208-
exit 1
209-
fi
210-
62+
pull-requests: write # to be able to comment on PR
63+
steps:
21164
- name: Update sample builds PR comment with build information
212-
if: ${{ github.event_name == 'pull_request' }}
65+
if: ${{ needs.build-sample-apps.result == 'success' }}
21366
uses: peter-evans/create-or-update-comment@v4
21467
with:
21568
comment-id: ${{ needs.update-pr-comment.outputs.comment-id }}
21669
issue-number: ${{ github.event.pull_request.number }}
21770
# the variables APP_VERSION_NAME, APP_VERSION_CODE are created when fastlane runs "build".
21871
body: |
219-
* ${{ matrix.sample-app.name }}: `${{ env.APP_VERSION_NAME }} (${{ env.APP_VERSION_CODE }})`
72+
* amiapp_flutter: `${{ env.APP_VERSION_NAME }} (${{ env.APP_VERSION_CODE }})`
22073
edit-mode: append # append new line to the existing PR comment to build a list of all sample app builds.
22174

22275
- name: Update sample builds PR comment with build failure message
223-
if: ${{ github.event_name == 'pull_request' && failure() }}
76+
if: ${{ needs.build-sample-apps.result == 'failure' }}
22477
uses: peter-evans/create-or-update-comment@v4
22578
with:
22679
comment-id: ${{ needs.update-pr-comment.outputs.comment-id }}
22780
issue-number: ${{ github.event.pull_request.number }}
22881
body: |
229-
* ${{ matrix.sample-app.name }}: Build failed. See [CI job logs](https://github.com/${{github.repository}}/actions/runs/${{github.run_id}}) to determine the issue and try re-building.
82+
* amiapp_flutter: Build failed. See [CI job logs](https://github.com/${{github.repository}}/actions/runs/${{github.run_id}}) to determine the issue and try re-building.
23083
edit-mode: append # append new line to the existing PR comment to build a list of all sample app builds.

0 commit comments

Comments
 (0)