Skip to content

Commit 158f110

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 ecf5cfa commit 158f110

1 file changed

Lines changed: 129 additions & 0 deletions

File tree

Lines changed: 129 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,129 @@
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: workflow fails early if unset (guard step after checkout).
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+
- name: Verify KLAVIYO_EXAMPLE_API_KEY secret is set
32+
run: |
33+
if [ -z "${KLAVIYO_EXAMPLE_API_KEY}" ]; then
34+
echo "::error::KLAVIYO_EXAMPLE_API_KEY secret is not set. The workflow cannot proceed — the build would produce an app that crashes at launch."
35+
exit 1
36+
fi
37+
shell: bash
38+
env:
39+
KLAVIYO_EXAMPLE_API_KEY: ${{ secrets.KLAVIYO_EXAMPLE_API_KEY }}
40+
41+
# Node + Yarn 3 + workspace deps. Required because the React Native Gradle plugin
42+
# invokes the Metro bundler during bundleRelease to generate the JS bundle. Installs
43+
# the example workspace too, making react-native and its CLI available to Gradle.
44+
- name: Setup
45+
uses: ./.github/actions/setup
46+
47+
- name: Set up JDK 17
48+
uses: actions/setup-java@v4
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+
# The guard step above ensures the secret is set before we reach this point.
63+
- name: Write .env with Klaviyo API key
64+
run: echo "KLAVIYO_API_KEY=${KLAVIYO_EXAMPLE_API_KEY}" > example/.env
65+
env:
66+
KLAVIYO_EXAMPLE_API_KEY: ${{ secrets.KLAVIYO_EXAMPLE_API_KEY }}
67+
68+
# bundleRelease triggers react-native bundle automatically via the RN Gradle plugin.
69+
# We cd into the android directory so that relative paths in settings.gradle resolve correctly.
70+
- name: Assemble Release Bundle
71+
run: cd example/android && ./gradlew :app:bundleRelease
72+
env:
73+
# Prevent Metro from trying to start a dev server during the build
74+
CI: true
75+
76+
- name: Sign Release
77+
id: sign_release
78+
uses: r0adkll/sign-android-release@v1
79+
with:
80+
releaseDirectory: example/android/app/build/outputs/bundle/release
81+
signingKeyBase64: ${{ secrets.SIGNING_KEY }}
82+
alias: ${{ secrets.ALIAS }}
83+
keyStorePassword: ${{ secrets.KEY_STORE_PASSWORD }}
84+
keyPassword: ${{ secrets.KEY_PASSWORD }}
85+
86+
- name: Deploy to Internal Track
87+
uses: r0adkll/[email protected]
88+
with:
89+
serviceAccountJsonPlainText: ${{ secrets.SERVICE_ACCOUNT_JSON }}
90+
packageName: com.klaviyoreactnativesdkexample
91+
releaseFiles: ${{ steps.sign_release.outputs.signedReleaseFile }}
92+
track: internal
93+
status: completed
94+
95+
- name: Notify Slack on success
96+
if: success()
97+
uses: slackapi/[email protected]
98+
with:
99+
webhook: ${{ secrets.SLACK_WEBHOOK_URL }}
100+
webhook-type: incoming-webhook
101+
payload: |
102+
text: "✅ RN SDK Example App published to Play Store internal track"
103+
blocks:
104+
- type: "section"
105+
text:
106+
type: "mrkdwn"
107+
text: "*Repository:* ${{ github.repository }}\n*Workflow:* ${{ github.workflow }}\n*Release:* `${{ github.event.release.tag_name || 'manual' }}`\n*Commit:* `${{ github.sha }}`\n*Author:* ${{ github.actor }}"
108+
- type: "section"
109+
text:
110+
type: "mrkdwn"
111+
text: "*Workflow Run:* <${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}|View Details>"
112+
113+
- name: Notify Slack on failure
114+
if: failure()
115+
uses: slackapi/[email protected]
116+
with:
117+
webhook: ${{ secrets.SLACK_WEBHOOK_URL }}
118+
webhook-type: incoming-webhook
119+
payload: |
120+
text: "🚨 RN SDK Example App Play Store publish failed"
121+
blocks:
122+
- type: "section"
123+
text:
124+
type: "mrkdwn"
125+
text: "*Repository:* ${{ github.repository }}\n*Workflow:* ${{ github.workflow }}\n*Release:* `${{ github.event.release.tag_name || 'manual' }}`\n*Commit:* `${{ github.sha }}`\n*Author:* ${{ github.actor }}"
126+
- type: "section"
127+
text:
128+
type: "mrkdwn"
129+
text: "*Workflow Run:* <${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}|View Details>"

0 commit comments

Comments
 (0)