Skip to content

Commit 5fd44ad

Browse files
committed
chore: public release builds
1 parent 0e74e8c commit 5fd44ad

File tree

9 files changed

+258
-148
lines changed

9 files changed

+258
-148
lines changed
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
name: Publish Release Sample App
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
sdk_version:
7+
description: "SDK version to build sample apps with (optional, defaults to latest)"
8+
required: false
9+
type: string
10+
11+
jobs:
12+
determine-sdk-version:
13+
runs-on: ubuntu-latest
14+
outputs:
15+
resolved_version: ${{ steps.get_version.outputs.sdk_version }}
16+
steps:
17+
- name: Get Latest SDK Version (if not provided)
18+
id: get_version
19+
run: |
20+
if [[ -z "${{ inputs.sdk_version }}" ]]; then
21+
LATEST_VERSION=$(npm show customerio-reactnative version)
22+
echo "Using latest SDK version: $LATEST_VERSION"
23+
echo "sdk_version=$LATEST_VERSION" >> $GITHUB_OUTPUT
24+
else
25+
echo "sdk_version=${{ inputs.sdk_version }}" >> $GITHUB_OUTPUT
26+
fi
27+
28+
build-sample-app:
29+
needs: determine-sdk-version
30+
uses: ./.github/workflows/build-sample-app.yml
31+
with:
32+
app_name: "APN"
33+
cio-workspace-name: "Mobile: React Native"
34+
sdk_version: ${{ needs.determine-sdk-version.outputs.resolved_version }}
35+
secrets: inherit
Original file line numberDiff line numberDiff line change
@@ -1,72 +1,34 @@
1-
name: Build sample apps
1+
name: Build Sample App
22

33
on:
4-
pull_request: # build sample apps for every commit pushed to an open pull request (including drafts)
5-
push:
6-
branches: [ main, feature/* ]
7-
8-
concurrency: # cancel previous workflow run if one exists.
9-
group: ${{ github.workflow }}-${{ github.ref }}
10-
cancel-in-progress: true
4+
workflow_call:
5+
inputs:
6+
app_name:
7+
description: "Name of the sample app to build"
8+
required: true
9+
type: string
10+
cio-workspace-name:
11+
description: "Name of the Customer.io workspace to use"
12+
required: true
13+
type: string
14+
sdk_version:
15+
default: ""
16+
description: "SDK version to use (optional, defaults to local dependency)"
17+
required: false
18+
type: string
1119

1220
env:
1321
XCODE_VERSION: "15.3"
1422
RUBY_VERSION: "3.0"
1523
NODE_VERSION: "18"
1624

1725
jobs:
18-
update-pr-comment:
19-
if: ${{ github.event_name == 'pull_request' }}
20-
runs-on: ubuntu-latest
21-
permissions:
22-
pull-requests: write # to be able to comment on PR
23-
outputs:
24-
comment-id: ${{ steps.create-comment.outputs.comment-id }}
25-
steps:
26-
- name: Find Comment
27-
uses: peter-evans/find-comment@v3
28-
id: existing-comment
29-
with:
30-
issue-number: ${{ github.event.pull_request.number }}
31-
comment-author: "github-actions[bot]"
32-
body-includes: <!-- sample app builds -->
33-
34-
- name: Create or update comment
35-
uses: peter-evans/create-or-update-comment@v4
36-
id: create-comment
37-
with:
38-
comment-id: ${{ steps.existing-comment.outputs.comment-id }}
39-
issue-number: ${{ github.event.pull_request.number }}
40-
body: |
41-
<!-- sample app builds -->
42-
# Sample app builds 📱
43-
44-
Below you will find the list of the latest versions of the sample apps. It's recommended to always download the latest builds of the sample apps to accurately test the pull request.
45-
46-
---
47-
${{ steps.build.outputs.build-log }}
48-
edit-mode: replace # replace the existing comment with new content since we are creating new builds
49-
50-
build-sample-apps:
51-
if: ${{ always() }} # do not skip running this step if update-pr-comment does not run
52-
needs: [update-pr-comment] # wait for PR comment to be created saying new builds are being made.
53-
permissions:
54-
pull-requests: write # comment on pull request with build information
55-
strategy:
56-
fail-fast: false # if one sample app fails to build, let the other sample apps continue to build and not cancel them.
57-
matrix: # Use a matrix allowing us to build multiple apps in parallel. Just add an entry to the matrix and it will build!
58-
sample-app:
59-
# List all sample apps you want to have compiled.
60-
# List item is name of directory inside of "Apps" directory for the corresponding app to compile.
61-
- name: "APN"
62-
cio-workspace-name: "Mobile: React Native"
63-
- name: "FCM"
64-
cio-workspace-name: "Mobile: xReact Native FCM workspace"
26+
build-sample-app:
6527
defaults:
6628
run:
67-
working-directory: apps/${{ matrix.sample-app.name }}
29+
working-directory: Apps/${{ inputs.app_name }} # sets working directory for all steps in this job
6830
runs-on: macos-14
69-
name: Building sample app ${{ matrix.sample-app.name }}
31+
name: Building sample app ${{ inputs.app_name }} with SDK version ${{ inputs.sdk_version }}
7032

7133
steps:
7234
- name: Check out code with conditional fetch-depth
@@ -85,7 +47,7 @@ jobs:
8547
NEXT_BUILDS_GROUP: next
8648
PUBLIC_BUILDS_GROUP: public
8749
# Input variables
88-
IS_PRIMARY_APP: ${{ matrix.sample-app.name == 'APN' }}
50+
IS_PRIMARY_APP: ${{ inputs.app_name == 'APN' }}
8951
CURRENT_BRANCH: ${{ github.ref }}
9052
run: |
9153
# Initialize with the default distribution group
@@ -95,7 +57,7 @@ jobs:
9557
if [[ "$IS_PRIMARY_APP" == "true" ]]; then
9658
[[ "$CURRENT_BRANCH" == "refs/heads/feature/"* ]] && distribution_groups+=("$FEATURE_BUILDS_GROUP")
9759
[[ "$CURRENT_BRANCH" == "refs/heads/main" ]] && distribution_groups+=("$NEXT_BUILDS_GROUP")
98-
[[ "$CURRENT_BRANCH" == "refs/heads/main" ]] && distribution_groups+=("$PUBLIC_BUILDS_GROUP")
60+
[[ -n "${{ inputs.sdk_version }}" ]] && distribution_groups+=("$PUBLIC_BUILDS_GROUP")
9961
fi
10062
10163
# Export the groups as an environment variable
@@ -112,21 +74,21 @@ jobs:
11274
with:
11375
ruby-version: ${{ env.RUBY_VERSION }}
11476
bundler-cache: true # cache tools to make builds faster in future
115-
working-directory: apps/${{ matrix.sample-app.name }}
77+
working-directory: Apps/${{ inputs.app_name }}
11678

11779
# Update version numbers and workspace credentials before building the app
11880

11981
- name: Generate New Version
12082
uses: maierj/fastlane-action@v3.1.0
12183
with:
122-
subdirectory: Apps/${{ matrix.sample-app.name }}
84+
subdirectory: Apps/${{ inputs.app_name }}
12385
lane: "generate_new_version"
124-
options: '{"branch_name":"${{ github.ref_name }}", "pull_request_number":"${{ github.event.pull_request.number }}"}'
86+
options: '{"branch_name":"${{ github.ref_name }}", "pull_request_number":"${{ github.event.pull_request.number }}", "sdk_version":"${{ inputs.sdk_version }}"}'
12587

12688
- name: Update React Native SDK Version
12789
uses: maierj/fastlane-action@v3.1.0
12890
with:
129-
subdirectory: Apps/${{ matrix.sample-app.name }}
91+
subdirectory: Apps/${{ inputs.app_name }}
13092
lane: "update_react_native_sdk_version"
13193
env:
13294
SDK_VERSION_NAME: ${{ env.SDK_VERSION_NAME }}
@@ -136,7 +98,7 @@ jobs:
13698
- name: Update Sample App Version
13799
uses: maierj/fastlane-action@v3.1.0
138100
with:
139-
subdirectory: Apps/${{ matrix.sample-app.name }}
101+
subdirectory: Apps/${{ inputs.app_name }}
140102
lane: "update_react_native_app_version"
141103
env:
142104
SDK_VERSION_NAME: ${{ env.SDK_VERSION_NAME }}
@@ -172,7 +134,7 @@ jobs:
172134
sd "commitsAheadCount: '.*'" "commitsAheadCount: '$COMMITS_AHEAD'" "$ENV_FILE"
173135
174136
- name: Setup workspace credentials in iOS environment files
175-
working-directory: Apps/${{ matrix.sample-app.name }}/ios
137+
working-directory: Apps/${{ inputs.app_name }}/ios
176138
run: |
177139
cp "Env.swift.example" "Env.swift"
178140
sd 'siteId: String = ".*"' "siteId: String = \"${{ secrets[format('CUSTOMERIO_{0}_WORKSPACE_SITE_ID', matrix.sample-app.name)] }}\"" "Env.swift"
@@ -190,18 +152,24 @@ jobs:
190152
- name: Cache CocoaPods downloaded dependencies for faster builds in the future
191153
uses: actions/cache@v4
192154
with:
193-
path: Apps/${{ matrix.sample-app.name }}/Pods
194-
key: ${{ runner.os }}-${{ matrix.sample-app.name }}-Pods-${{ github.ref }}
155+
path: Apps/${{ inputs.app_name }}/Pods
156+
key: ${{ runner.os }}-${{ inputs.app_name }}-Pods-${{ github.ref }}
195157
restore-keys: |
196-
${{ runner.os }}-${{ matrix.sample-app.name }}-Pods
158+
${{ runner.os }}-${{ inputs.app_name }}-Pods
197159
198160
- name: Install dependencies to build SDK
199161
run: npm ci
200162
working-directory: .
201163

202164
- name: Install dependencies for sample app
203-
run: npm run ci:install
204-
165+
run: |
166+
SDK_VERSION="${{ inputs.sdk_version }}"
167+
if [[ -n "$SDK_VERSION" ]]; then
168+
npm run ci:install -- --cio-rn-sdk=$SDK_VERSION
169+
else
170+
npm run ci:install
171+
fi
172+
205173
# Android setup
206174

207175
- name: Setup Android environment for sample app
@@ -211,7 +179,7 @@ jobs:
211179
id: android_build
212180
uses: maierj/fastlane-action@v3.1.0
213181
with:
214-
subdirectory: Apps/${{ matrix.sample-app.name }}
182+
subdirectory: Apps/${{ inputs.app_name }}
215183
lane: 'android build'
216184
options: '{"distribution_groups": "${{ env.firebase_distribution_groups }}"}'
217185
env:
@@ -229,7 +197,7 @@ jobs:
229197
id: ios_build
230198
uses: maierj/fastlane-action@v3.1.0
231199
with:
232-
subdirectory: Apps/${{ matrix.sample-app.name }}
200+
subdirectory: Apps/${{ inputs.app_name }}
233201
lane: "ios build"
234202
options: '{"distribution_groups": "${{ env.firebase_distribution_groups }}"}'
235203
env:
@@ -238,30 +206,11 @@ jobs:
238206

239207
- name: Check build statuses and mark failure
240208
run: |
241-
if [ "${{ steps.android_build.outcome }}" != "success" ] || [ "${{ steps.ios_build.outcome }}" != "success" ]; then
242-
echo "One or more builds failed."
209+
FAILED_BUILDS=()
210+
[ "${{ steps.android_build.outcome }}" != "success" ] && FAILED_BUILDS+=("Android")
211+
[ "${{ steps.ios_build.outcome }}" != "success" ] && FAILED_BUILDS+=("iOS")
212+
213+
if [ ${#FAILED_BUILDS[@]} -ne 0 ]; then
214+
echo "Build failed for: ${FAILED_BUILDS[*]}"
243215
exit 1
244216
fi
245-
246-
# Update PR comment with build information
247-
248-
- name: Update sample builds PR comment with build information
249-
if: ${{ github.event_name == 'pull_request' }}
250-
uses: peter-evans/create-or-update-comment@v3
251-
with:
252-
comment-id: ${{ needs.update-pr-comment.outputs.comment-id }}
253-
issue-number: ${{ github.event.pull_request.number }}
254-
# the variables APP_VERSION_NAME, APP_VERSION_CODE are generated above in generate_new_version lane
255-
body: |
256-
* ${{ matrix.sample-app.name }}: `${{ env.APP_VERSION_NAME }} (${{ env.APP_VERSION_CODE }})`
257-
edit-mode: append # append new line to the existing PR comment to build a list of all sample app builds.
258-
259-
- name: Update sample builds PR comment with build failure message
260-
if: ${{ github.event_name == 'pull_request' && failure() }}
261-
uses: peter-evans/create-or-update-comment@v3
262-
with:
263-
comment-id: ${{ needs.update-pr-comment.outputs.comment-id }}
264-
issue-number: ${{ github.event.pull_request.number }}
265-
body: |
266-
* ${{ 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.
267-
edit-mode: append # append new line to the existing PR comment to build a list of all sample app builds.
Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
name: Publish Test Sample Apps
2+
3+
on:
4+
pull_request: # build sample apps for every commit pushed to an open pull request (including drafts)
5+
push:
6+
branches: [ main, feature/* ]
7+
8+
concurrency: # cancel previous workflow run if one exists.
9+
group: ${{ github.workflow }}-${{ github.ref }}
10+
cancel-in-progress: true
11+
12+
jobs:
13+
update-pr-comment:
14+
if: ${{ github.event_name == 'pull_request' }}
15+
runs-on: ubuntu-latest
16+
permissions:
17+
pull-requests: write # to be able to comment on PR
18+
outputs:
19+
comment-id: ${{ steps.create-comment.outputs.comment-id }}
20+
steps:
21+
- name: Find Comment
22+
uses: peter-evans/find-comment@v3
23+
id: existing-comment
24+
with:
25+
issue-number: ${{ github.event.pull_request.number }}
26+
comment-author: "github-actions[bot]"
27+
body-includes: <!-- sample app builds -->
28+
29+
- name: Create or update comment
30+
uses: peter-evans/create-or-update-comment@v4
31+
id: create-comment
32+
with:
33+
comment-id: ${{ steps.existing-comment.outputs.comment-id }}
34+
issue-number: ${{ github.event.pull_request.number }}
35+
body: |
36+
<!-- sample app builds -->
37+
# Sample app builds 📱
38+
39+
Below you will find the list of the latest versions of the sample apps. It's recommended to always download the latest builds of the sample apps to accurately test the pull request.
40+
41+
---
42+
${{ steps.build.outputs.build-log }}
43+
edit-mode: replace # replace the existing comment with new content since we are creating new builds
44+
45+
build-sample-apps:
46+
if: ${{ always() }} # do not skip running this step if update-pr-comment does not run
47+
needs: [update-pr-comment] # wait for PR comment to be created saying new builds are being made.
48+
strategy:
49+
fail-fast: false # if one sample app fails to build, let the other sample apps continue to build and not cancel them.
50+
matrix: # Use a matrix allowing us to build multiple apps in parallel. Just add an entry to the matrix and it will build!
51+
sample-app:
52+
# List all sample apps you want to have compiled.
53+
# List item is name of directory inside of "Apps" directory for the corresponding app to compile.
54+
- name: "APN"
55+
cio-workspace-name: "Mobile: React Native"
56+
- name: "FCM"
57+
cio-workspace-name: "Mobile: xReact Native FCM workspace"
58+
name: Building sample app ${{ matrix.sample-app.name }}
59+
uses: ./.github/workflows/build-sample-app.yml
60+
with:
61+
app_name: ${{ matrix.sample-app.name }}
62+
cio-workspace-name: ${{ matrix.sample-app.cio-workspace-name }}
63+
secrets: inherit
64+
65+
# Update PR comment with build information
66+
update-pr-comment-with-status:
67+
if: ${{ github.event_name == 'pull_request' }}
68+
needs: [build-sample-apps, update-pr-comment]
69+
runs-on: ubuntu-latest
70+
permissions:
71+
pull-requests: write # to be able to comment on PR
72+
steps:
73+
- name: Update sample builds PR comment with build information
74+
if: ${{ github.event_name == 'pull_request' }}
75+
uses: peter-evans/create-or-update-comment@v3
76+
with:
77+
comment-id: ${{ needs.update-pr-comment.outputs.comment-id }}
78+
issue-number: ${{ github.event.pull_request.number }}
79+
# the variables APP_VERSION_NAME, APP_VERSION_CODE are generated above in generate_new_version lane
80+
body: |
81+
* ${{ matrix.sample-app.name }}: `${{ env.APP_VERSION_NAME }} (${{ env.APP_VERSION_CODE }})`
82+
edit-mode: append # append new line to the existing PR comment to build a list of all sample app builds.
83+
84+
- name: Update sample builds PR comment with build failure message
85+
if: ${{ github.event_name == 'pull_request' && failure() }}
86+
uses: peter-evans/create-or-update-comment@v3
87+
with:
88+
comment-id: ${{ needs.update-pr-comment.outputs.comment-id }}
89+
issue-number: ${{ github.event.pull_request.number }}
90+
body: |
91+
* ${{ 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.
92+
edit-mode: append # append new line to the existing PR comment to build a list of all sample app builds.

Apps/APN/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@
99
"clean-install": "./scripts/clean-install-dependencies.sh",
1010
"clean-install-android": "./scripts/clean-run-android.sh",
1111
"clean-install-ios": "./scripts/clean-run-ios.sh",
12-
"dev:update": "../../scripts/dev:update.sh",
12+
"install-sdk-deps": "CIO_PACKAGE_VERSION=$npm_config_cio_rn_sdk ../../scripts/install-sdk-deps.sh",
13+
"preinstall": "npm run install-sdk-deps",
1314
"postinstall": "pod update --project-directory=ios",
14-
"preinstall": "npm run dev:update",
1515
"ci:install": "npm run preinstall && npm ci"
1616
},
1717
"dependencies": {

Apps/FCM/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44
"ios": "react-native run-ios",
55
"lint": "eslint .",
66
"start": "react-native start",
7-
"dev:update": "../../scripts/dev:update.sh",
7+
"install-sdk-deps": "CIO_PACKAGE_VERSION=$npm_config_cio_rn_sdk ../../scripts/install-sdk-deps.sh",
8+
"preinstall": "npm run install-sdk-deps",
89
"postinstall": "pod update --project-directory=ios",
9-
"preinstall": "npm run dev:update",
1010
"ci:install": "npm run preinstall && npm ci"
1111
},
1212
"dependencies": {

0 commit comments

Comments
 (0)