Skip to content
This repository was archived by the owner on Aug 30, 2024. It is now read-only.

Commit ead7b4d

Browse files
authored
Merge pull request #11 from dolbyio-samples/setup/CD-Android-Firebase
[Android] Firebase deployment
2 parents 92327ac + e00e6ed commit ead7b4d

File tree

4 files changed

+64
-16
lines changed

4 files changed

+64
-16
lines changed

.github/workflows/cd_android.yml

Lines changed: 55 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ name: CD Android build and distribution
33
on:
44
push:
55
branches:
6-
- main
6+
- main
77
tags:
8-
- '*'
8+
- '*'
99

1010
jobs:
1111
Android-App-Build:
@@ -27,17 +27,6 @@ jobs:
2727
path: ~/.gradle/wrapper
2828
key: ${{ runner.os }}-gradle-wrapper-${{ hashFiles('gradle/wrapper/gradle-wrapper.properties') }}
2929

30-
- name: create google-services.json
31-
env:
32-
GOOGLE_SERVICES : ${{secrets.GOOGLE_SERVICES_ANDROID}}
33-
run: |
34-
echo $GOOGLE_SERVICES >> ./examples/mobile/android/app/google-services.json
35-
ls ./examples/mobile/android/app/
36-
37-
- name: update gradle plugins for google services
38-
run: |
39-
echo 'apply plugin: "com.google.gms.google-services"' >> examples/mobile/android/app/plugins.gradle
40-
4130
- name: Install the signing certificate
4231
env:
4332
DISTRIBUTION_CERTIFICATE_ANDROID_BASE64: ${{ secrets.RELEASE_KEYSTORE_BASE64 }}
@@ -55,7 +44,7 @@ jobs:
5544
- name: calculate version
5645
run: |
5746
versionName='1.0.'$GITHUB_RUN_NUMBER
58-
versionCode=$(($GITHUB_RUN_NUMBER+33)); echo "versionName: $versionName; versionCode: $versionCode"
47+
versionCode=$GITHUB_RUN_NUMBER; echo "versionName: $versionName; versionCode: $versionCode"
5948
echo "export VERSION_NAME=$versionName; export VERSION_CODE=$versionCode" > ~/.env_version
6049
6150
- name: Beta Android App Build
@@ -77,6 +66,58 @@ jobs:
7766
path: |
7867
./examples/mobile/android/app/build/outputs/bundle/release/app-release.aab
7968
69+
Android-Firebase-Distribution:
70+
needs: Android-App-Build
71+
runs-on: ubuntu-latest
72+
steps:
73+
- name: Checkout source code
74+
uses: actions/checkout@v3
75+
- uses: actions/setup-node@master
76+
- name: Install modules
77+
run: yarn install
78+
- name: Set up JDK 11
79+
uses: actions/setup-java@v3
80+
with:
81+
distribution: "zulu"
82+
java-version: 11
83+
- name: Cache Gradle Wrapper
84+
uses: actions/cache@v3
85+
with:
86+
path: ~/.gradle/wrapper
87+
key: ${{ runner.os }}-gradle-wrapper-${{ hashFiles('gradle/wrapper/gradle-wrapper.properties') }}
88+
89+
- name: Download release artifacts
90+
uses: actions/download-artifact@v3
91+
with:
92+
name: android-release-apk
93+
path: ./examples/mobile/android/app/build/outputs/apk/release
94+
95+
- name: 'Export Firebase App Id and Credentials'
96+
env:
97+
FIREBASE_APP_ID_ANDROID: ${{secrets.FIREBASE_APP_ID_ANDROID}}
98+
GOOGLE_APPLICATION_CREDENTIALS_KEY: ${{secrets.GOOGLE_APPLICATION_CREDENTIALS}}
99+
run: |
100+
echo $GOOGLE_APPLICATION_CREDENTIALS_KEY >> $GITHUB_WORKSPACE/google-app-creds.json
101+
echo "export FIREBASE_APP_ID=$FIREBASE_APP_ID_ANDROID; export GOOGLE_APPLICATION_CREDENTIALS=$GITHUB_WORKSPACE/google-app-creds.json" > ~/.env_creds
102+
103+
- name: calculate version
104+
run: |
105+
versionName='1.0.'$GITHUB_RUN_NUMBER
106+
versionCode=$GITHUB_RUN_NUMBER;
107+
echo "export VERSION_NAME=$versionName; export VERSION_CODE=$versionCode" > ~/.env_version
108+
109+
- name: create google-services.json
110+
env:
111+
GOOGLE_SERVICES : ${{secrets.GOOGLE_SERVICES_ANDROID}}
112+
run: |
113+
echo $GOOGLE_SERVICES >> ./examples/mobile/android/app/google-services.json
114+
115+
- name: Deploy to Firebase
116+
run: |
117+
source ~/.env_version
118+
source ~/.env_creds
119+
cd examples/mobile/android && gradle appDistributionUploadRelease --stacktrace
120+
80121
Android-Play-Store-Distribution:
81122
if: github.event_name == 'push' && contains(github.ref, 'refs/tags/')
82123
needs: Android-App-Build

examples/mobile/android/app/build.gradle

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,7 @@ def nativeArchitectures = project.getProperties().get("reactNativeDebugArchitect
131131

132132
def appVersionCode = Integer.valueOf(System.env.VERSION_CODE ?: 1)
133133
def appVersionName = System.env.VERSION_NAME ?: "1.0"
134+
def firebaseAppId = System.env.FIREBASE_APP_ID ?: ""
134135

135136
android {
136137
ndkVersion rootProject.ext.ndkVersion
@@ -182,6 +183,13 @@ android {
182183
minifyEnabled enableProguardInReleaseBuilds
183184
proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
184185

186+
firebaseAppDistribution {
187+
artifactType = "APK"
188+
releaseNotes = "Release notes"
189+
groups = "internal"
190+
appId = firebaseAppId
191+
artifactPath = "app/build/outputs/apk/release/app-release.apk"
192+
}
185193
play {
186194
track.set("internal")
187195
}

examples/mobile/android/app/plugins.gradle

Whitespace-only changes.

examples/mobile/android/build.gradle

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,7 @@ buildscript {
1616
classpath("com.android.tools.build:gradle:4.2.2")
1717
// NOTE: Do not place your application dependencies here; they belong
1818
// in the individual module build.gradle files
19-
classpath 'com.google.gms:google-services:4.3.13'
20-
classpath 'com.google.firebase:firebase-appdistribution-gradle:3.0.3'
19+
classpath 'com.google.firebase:firebase-appdistribution-gradle:3.1.0'
2120
classpath("com.github.triplet.gradle:play-publisher:3.7.0-agp4.2")
2221
}
2322
}

0 commit comments

Comments
 (0)