Skip to content

Commit 7d94eae

Browse files
committed
ci(example): add Play Store internal track publish workflow
Adds a GitHub Actions workflow to build and publish the React Native SDK example app (com.klaviyoreactnativesdkexample) to the Google Play internal track. Fires on SDK releases and manual workflow_dispatch. Includes Node 20 + Yarn 3 setup, JS bundle generation via the RN Gradle plugin (bundleRelease), signing with r0adkll/sign-android-release, and Slack notifications for both success and failure. Part of MAGE-464
1 parent 45c423d commit 7d94eae

1 file changed

Lines changed: 130 additions & 0 deletions

File tree

Lines changed: 130 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,130 @@
1+
# Publish the React Native SDK example app to Google Play Console internal track.
2+
#
3+
# Triggers:
4+
# - workflow_dispatch: Manual publish (preferred — SDK releases don't map 1:1 to example app publishes)
5+
# - release: published: Fires on every SDK release to keep the example app in sync
6+
#
7+
# Required secrets (set in repo Settings → Secrets and variables → Actions):
8+
# GOOGLE_SERVICES_JSON - Contents of google-services.json for Firebase
9+
# SIGNING_KEY - Base64-encoded release keystore
10+
# ALIAS - Key alias in the keystore
11+
# KEY_STORE_PASSWORD - Keystore password
12+
# KEY_PASSWORD - Key password
13+
# SERVICE_ACCOUNT_JSON - Google Play service account JSON (plain text)
14+
# KLAVIYO_EXAMPLE_API_KEY - Klaviyo public API key for the example app build.
15+
# Required: the build fails if unset.
16+
17+
name: Publish Example App to Play Store Internal Track
18+
19+
on:
20+
workflow_dispatch:
21+
release:
22+
types: [ published ]
23+
24+
jobs:
25+
deploy:
26+
runs-on: ubuntu-22.04
27+
28+
steps:
29+
- uses: actions/checkout@v4
30+
31+
# Node is required because the React Native Gradle plugin invokes the Metro bundler
32+
# during bundleRelease to generate the JS bundle. Without it, the Gradle task fails.
33+
- name: Set up Node
34+
uses: actions/setup-node@v4
35+
with:
36+
node-version: '20'
37+
38+
# Enable Yarn 3 (corepack ships with Node 16+; activate it so `yarn` resolves to 3.x)
39+
- name: Enable Corepack / Yarn 3
40+
run: corepack enable
41+
42+
# Install all workspace dependencies from the repo root. This also installs the
43+
# example workspace, making react-native and its CLI available for the Gradle plugin.
44+
- name: Install JS dependencies
45+
run: yarn install --immutable
46+
47+
- name: Set up JDK 17
48+
uses: actions/setup-java@v3
49+
with:
50+
distribution: 'zulu'
51+
java-version: '17'
52+
java-package: jdk
53+
54+
- name: Add Google Services from Secrets
55+
run: 'echo "$GOOGLE_SERVICES_JSON" > ./example/android/app/google-services.json'
56+
shell: bash
57+
env:
58+
GOOGLE_SERVICES_JSON: ${{ secrets.GOOGLE_SERVICES_JSON }}
59+
60+
# Write the Klaviyo public API key into example/.env so react-native-dotenv
61+
# can expose it to the JS layer as KLAVIYO_API_KEY (imported from '@env').
62+
# App.tsx throws at module load if the key is missing, so an unset secret
63+
# will fail the bundling step with a clear error.
64+
- name: Write .env with Klaviyo API key
65+
run: echo "KLAVIYO_API_KEY=${KLAVIYO_EXAMPLE_API_KEY}" > example/.env
66+
env:
67+
KLAVIYO_EXAMPLE_API_KEY: ${{ secrets.KLAVIYO_EXAMPLE_API_KEY }}
68+
69+
# bundleRelease triggers react-native bundle automatically via the RN Gradle plugin.
70+
# We cd into the android directory so that relative paths in settings.gradle resolve correctly.
71+
- name: Assemble Release Bundle
72+
run: cd example/android && ./gradlew :app:bundleRelease
73+
env:
74+
# Prevent Metro from trying to start a dev server during the build
75+
CI: true
76+
77+
- name: Sign Release
78+
id: sign_release
79+
uses: r0adkll/sign-android-release@v1
80+
with:
81+
releaseDirectory: example/android/app/build/outputs/bundle/release
82+
signingKeyBase64: ${{ secrets.SIGNING_KEY }}
83+
alias: ${{ secrets.ALIAS }}
84+
keyStorePassword: ${{ secrets.KEY_STORE_PASSWORD }}
85+
keyPassword: ${{ secrets.KEY_PASSWORD }}
86+
87+
- name: Deploy to Internal Track
88+
uses: r0adkll/[email protected]
89+
with:
90+
serviceAccountJsonPlainText: ${{ secrets.SERVICE_ACCOUNT_JSON }}
91+
packageName: com.klaviyoreactnativesdkexample
92+
releaseFiles: ${{ steps.sign_release.outputs.signedReleaseFile }}
93+
track: internal
94+
status: completed
95+
96+
- name: Notify Slack on success
97+
if: success()
98+
uses: slackapi/[email protected]
99+
with:
100+
webhook: ${{ secrets.SLACK_WEBHOOK_URL }}
101+
webhook-type: incoming-webhook
102+
payload: |
103+
text: "✅ RN SDK Example App published to Play Store internal track"
104+
blocks:
105+
- type: "section"
106+
text:
107+
type: "mrkdwn"
108+
text: "*Repository:* ${{ github.repository }}\n*Workflow:* ${{ github.workflow }}\n*Release:* `${{ github.event.release.tag_name || 'manual' }}`\n*Commit:* `${{ github.sha }}`\n*Author:* ${{ github.actor }}"
109+
- type: "section"
110+
text:
111+
type: "mrkdwn"
112+
text: "*Workflow Run:* <${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}|View Details>"
113+
114+
- name: Notify Slack on failure
115+
if: failure()
116+
uses: slackapi/[email protected]
117+
with:
118+
webhook: ${{ secrets.SLACK_WEBHOOK_URL }}
119+
webhook-type: incoming-webhook
120+
payload: |
121+
text: "🚨 RN SDK Example App Play Store publish failed"
122+
blocks:
123+
- type: "section"
124+
text:
125+
type: "mrkdwn"
126+
text: "*Repository:* ${{ github.repository }}\n*Workflow:* ${{ github.workflow }}\n*Release:* `${{ github.event.release.tag_name || 'manual' }}`\n*Commit:* `${{ github.sha }}`\n*Author:* ${{ github.actor }}"
127+
- type: "section"
128+
text:
129+
type: "mrkdwn"
130+
text: "*Workflow Run:* <${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}|View Details>"

0 commit comments

Comments
 (0)