|
| 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 | +# (currently defaults to TRJ3wp for the internal test company; |
| 16 | +# swap to a dedicated secret before publishing to a production account) |
| 17 | + |
| 18 | +name: Publish Example App to Play Store Internal Track |
| 19 | + |
| 20 | +on: |
| 21 | + workflow_dispatch: |
| 22 | + release: |
| 23 | + types: [ published ] |
| 24 | + |
| 25 | +jobs: |
| 26 | + deploy: |
| 27 | + runs-on: ubuntu-22.04 |
| 28 | + |
| 29 | + steps: |
| 30 | + - uses: actions/checkout@v4 |
| 31 | + |
| 32 | + # Node is required because the React Native Gradle plugin invokes the Metro bundler |
| 33 | + # during bundleRelease to generate the JS bundle. Without it, the Gradle task fails. |
| 34 | + - name: Set up Node |
| 35 | + uses: actions/setup-node@v4 |
| 36 | + with: |
| 37 | + node-version: '20' |
| 38 | + |
| 39 | + # Enable Yarn 3 (corepack ships with Node 16+; activate it so `yarn` resolves to 3.x) |
| 40 | + - name: Enable Corepack / Yarn 3 |
| 41 | + run: corepack enable |
| 42 | + |
| 43 | + # Install all workspace dependencies from the repo root. This also installs the |
| 44 | + # example workspace, making react-native and its CLI available for the Gradle plugin. |
| 45 | + - name: Install JS dependencies |
| 46 | + run: yarn install --immutable |
| 47 | + |
| 48 | + - name: Set up JDK 17 |
| 49 | + uses: actions/setup-java@v3 |
| 50 | + with: |
| 51 | + distribution: 'zulu' |
| 52 | + java-version: '17' |
| 53 | + java-package: jdk |
| 54 | + |
| 55 | + - name: Add Google Services from Secrets |
| 56 | + run: 'echo "$GOOGLE_SERVICES_JSON" > ./example/android/app/google-services.json' |
| 57 | + shell: bash |
| 58 | + env: |
| 59 | + GOOGLE_SERVICES_JSON: ${{ secrets.GOOGLE_SERVICES_JSON }} |
| 60 | + |
| 61 | + # Inject the Klaviyo public API key into local.properties so the Gradle build can |
| 62 | + # embed it as a BuildConfig field. The key is read by example/android/app/build.gradle |
| 63 | + # via: def apiKey = localProperties['publicApiKey'] ?: publicApiKey |
| 64 | + # |
| 65 | + # TODO: Replace the fallback 'TRJ3wp' with a dedicated secret once KLAVIYO_EXAMPLE_API_KEY |
| 66 | + # is wired up in repo secrets. TRJ3wp is the internal MAGE test company public API key. |
| 67 | + - name: Inject Klaviyo API key into local.properties |
| 68 | + run: | |
| 69 | + API_KEY="${KLAVIYO_EXAMPLE_API_KEY:-TRJ3wp}" |
| 70 | + echo "publicApiKey=${API_KEY}" >> example/android/local.properties |
| 71 | + shell: bash |
| 72 | + env: |
| 73 | + KLAVIYO_EXAMPLE_API_KEY: ${{ secrets.KLAVIYO_EXAMPLE_API_KEY }} |
| 74 | + |
| 75 | + # bundleRelease triggers react-native bundle automatically via the RN Gradle plugin. |
| 76 | + # We cd into the android directory so that relative paths in settings.gradle resolve correctly. |
| 77 | + - name: Assemble Release Bundle |
| 78 | + run: cd example/android && ./gradlew :app:bundleRelease |
| 79 | + env: |
| 80 | + # Prevent Metro from trying to start a dev server during the build |
| 81 | + CI: true |
| 82 | + |
| 83 | + - name: Sign Release |
| 84 | + id: sign_release |
| 85 | + uses: r0adkll/sign-android-release@v1 |
| 86 | + with: |
| 87 | + releaseDirectory: example/android/app/build/outputs/bundle/release |
| 88 | + signingKeyBase64: ${{ secrets.SIGNING_KEY }} |
| 89 | + alias: ${{ secrets.ALIAS }} |
| 90 | + keyStorePassword: ${{ secrets.KEY_STORE_PASSWORD }} |
| 91 | + keyPassword: ${{ secrets.KEY_PASSWORD }} |
| 92 | + |
| 93 | + - name: Deploy to Internal Track |
| 94 | + |
| 95 | + with: |
| 96 | + serviceAccountJsonPlainText: ${{ secrets.SERVICE_ACCOUNT_JSON }} |
| 97 | + packageName: com.klaviyoreactnativesdkexample |
| 98 | + releaseFiles: example/android/app/build/outputs/bundle/release/app-release.aab |
| 99 | + track: internal |
| 100 | + status: completed |
| 101 | + |
| 102 | + - name: Notify Slack on success |
| 103 | + if: success() |
| 104 | + |
| 105 | + with: |
| 106 | + webhook: ${{ secrets.SLACK_WEBHOOK_URL }} |
| 107 | + webhook-type: incoming-webhook |
| 108 | + payload: | |
| 109 | + text: "✅ RN SDK Example App published to Play Store internal track" |
| 110 | + blocks: |
| 111 | + - type: "section" |
| 112 | + text: |
| 113 | + type: "mrkdwn" |
| 114 | + text: "✅ Published to Play Store internal track" |
| 115 | + - type: "section" |
| 116 | + text: |
| 117 | + type: "mrkdwn" |
| 118 | + text: "*Repository:* ${{ github.repository }}\n*Workflow:* ${{ github.workflow }}\n*Release:* `${{ github.event.release.tag_name || 'manual' }}`\n*Commit:* `${{ github.sha }}`\n*Author:* ${{ github.actor }}" |
| 119 | + - type: "section" |
| 120 | + text: |
| 121 | + type: "mrkdwn" |
| 122 | + text: "*Workflow Run:* <${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}|View Details>" |
| 123 | +
|
| 124 | + - name: Notify Slack on failure |
| 125 | + if: failure() |
| 126 | + |
| 127 | + with: |
| 128 | + webhook: ${{ secrets.SLACK_WEBHOOK_URL }} |
| 129 | + webhook-type: incoming-webhook |
| 130 | + payload: | |
| 131 | + text: "🚨 RN SDK Example App Play Store publish failed" |
| 132 | + blocks: |
| 133 | + - type: "section" |
| 134 | + text: |
| 135 | + type: "mrkdwn" |
| 136 | + text: "🚨 Play Store publish failed" |
| 137 | + - type: "section" |
| 138 | + text: |
| 139 | + type: "mrkdwn" |
| 140 | + text: "*Repository:* ${{ github.repository }}\n*Workflow:* ${{ github.workflow }}\n*Release:* `${{ github.event.release.tag_name || 'manual' }}`\n*Commit:* `${{ github.sha }}`\n*Author:* ${{ github.actor }}" |
| 141 | + - type: "section" |
| 142 | + text: |
| 143 | + type: "mrkdwn" |
| 144 | + text: "*Workflow Run:* <${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}|View Details>" |
0 commit comments