Skip to content

Commit 5ec0d18

Browse files
committed
Build release version of android app with publishing
1 parent 4d74d1e commit 5ec0d18

File tree

4 files changed

+186
-38
lines changed

4 files changed

+186
-38
lines changed

.github/actions/build-android/action.yaml

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,21 @@ inputs:
55
google_services_json:
66
description: 'Base64-encoded google-services.json file'
77
required: true
8+
firebaseAPIKey:
9+
description: 'Firebase API key'
10+
required: true
11+
keystorePath:
12+
description: 'Path to the Android keystore file'
13+
required: true
14+
keystoreAlias:
15+
description: 'Alias for the Android keystore'
16+
required: true
17+
keystorePassword:
18+
description: 'Password for the Android keystore'
19+
required: true
20+
keystoreKeyPassword:
21+
description: 'Key password for the Android keystore'
22+
required: true
823

924
runs:
1025
using: composite
@@ -38,9 +53,17 @@ runs:
3853
echo $GOOGLE_SERVICES_JSON | base64 --decode > android/app/google-services.json
3954
shell: bash
4055

41-
- name: Build Android APK with Fastlane
42-
run: npm run android:debug
56+
- name: Build Android Library with Fastlane
57+
run: |
58+
cd android
59+
fastlane android local
4360
shell: bash
61+
env:
62+
FIREBASE_API_KEY: ${{ inputs.firebaseAPIKey }}
63+
ANDROID_KEYSTORE_PATH: ${{ inputs.keystorePath }}
64+
ANDROID_KEYSTORE_PASSWORD: ${{ inputs.keystorePassword }}
65+
ANDROID_KEYSTORE_ALIAS: ${{ inputs.keystoreAlias }}
66+
ANDROID_KEYSTORE_KEY_PASSWORD: ${{ inputs.keystoreKeyPassword }}
4467

4568
- name: Copy Android APK to Shared Directory
4669
run: |

.github/workflows/MiNe2e.yaml

Lines changed: 38 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -96,15 +96,28 @@ jobs:
9696
name: mda
9797
path: automation.mda
9898

99-
# android-app:
100-
# runs-on: ubuntu-22.04
101-
# steps:
102-
# - name: "Check out code"
103-
# uses: actions/checkout@v4
104-
# - name: Build android apk
105-
# uses: ./.github/actions/build-android
106-
# with:
107-
# google_services_json: ${{ secrets.GOOGLE_SERVICES_JSON }}
99+
android-app:
100+
runs-on: ubuntu-22.04
101+
steps:
102+
- name: "Check out code"
103+
uses: actions/checkout@v4
104+
- name: Retrieve the secrets and decode it to a file
105+
env:
106+
UPLOAD_KEYSTORE_BASE64: ${{ secrets.UPLOAD_KEYSTORE_BASE64 }}
107+
PLAY_STORE_CREDENTIALS_BASE64: ${{ secrets.PLAY_STORE_CREDENTIALS_BASE64 }}
108+
run: |
109+
echo $UPLOAD_KEYSTORE_BASE64 | base64 --decode > ./android/keystores/upload.keystore
110+
echo $PLAY_STORE_CREDENTIALS_BASE64 | base64 --decode > ./android/fastlane/play-store-credentials.json
111+
shell: bash
112+
113+
- name: Build Android apk
114+
uses: ./.github/actions/build_android
115+
with:
116+
firebaseAPIKey: ${{ secrets.FIREBASE_API_KEY }}
117+
keystorePath: ${{ env.ANDROID_KEYSTORE_PATH }}
118+
keystoreAlias: ${{ secrets.ANDROID_KEYSTORE_ALIAS }}
119+
keystorePassword: ${{ secrets.ANDROID_KEYSTORE_PASSWORD }}
120+
keystoreKeyPassword: ${{ secrets.ANDROID_KEYSTORE_KEY_PASSWORD }}
108121

109122
ios-app:
110123
runs-on: macOS-15
@@ -210,23 +223,23 @@ jobs:
210223
bash maestro/helpers/prepare_android.sh
211224
bash maestro/run_maestro_tests.sh android
212225
213-
- name: "Capture emulator logs"
214-
if: always()
215-
continue-on-error: true
216-
run: |
217-
mkdir -p ${{ github.workspace }}/emulator-logs
218-
adb logcat -d > ${{ github.workspace }}/emulator-logs/emulator-logcat.txt
219-
adb shell dmesg > ${{ github.workspace }}/emulator-logs/emulator-dmesg.txt
220-
shell: bash
226+
# - name: "Capture emulator logs"
227+
# if: always()
228+
# continue-on-error: true
229+
# run: |
230+
# mkdir -p ${{ github.workspace }}/emulator-logs
231+
# adb logcat -d > ${{ github.workspace }}/emulator-logs/emulator-logcat.txt
232+
# adb shell dmesg > ${{ github.workspace }}/emulator-logs/emulator-dmesg.txt
233+
# shell: bash
221234

222-
- name: "Upload emulator logs"
223-
uses: actions/upload-artifact@4cec3d8aa04e39d1a68397de0c4cd6fb9dce8ec1 #v4
224-
continue-on-error: true
225-
if: always()
226-
with:
227-
name: emulator-logs
228-
path: ${{ github.workspace }}/emulator-logs/
229-
if-no-files-found: warn
235+
# - name: "Upload emulator logs"
236+
# uses: actions/upload-artifact@4cec3d8aa04e39d1a68397de0c4cd6fb9dce8ec1 #v4
237+
# continue-on-error: true
238+
# if: always()
239+
# with:
240+
# name: emulator-logs
241+
# path: ${{ github.workspace }}/emulator-logs/
242+
# if-no-files-found: warn
230243

231244
- name: "Debug root folder"
232245
if: always()

android/fastlane/Fastfile

Lines changed: 122 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,142 @@
11
# This file contains the fastlane.tools configuration
22
# You can find the documentation at https://docs.fastlane.tools
33

4+
# Uncomment the line if you want fastlane to automatically update itself
5+
# update_fastlane
6+
47
default_platform(:android)
58

9+
GOOGLE_PLAY_VERSION = sh("node -p -e \"require('../../package.json')['store-versions']['google-play']\"").chomp
10+
BUILD_NUMBER = ENV["BUILD_NUMBER"]
11+
TEST = ENV["TEST"]
12+
ORIGINAL_CHANGELOG_PATH = "../../CHANGELOG.android.txt"
13+
FASTLANE_CHANGELOG_PATH = "./metadata/android/en-US/changelogs/default.txt"
14+
versionCodeOffset = 304
15+
616
platform :android do
717
before_all do
818
Dir.chdir("../..") do
9-
sh("npm", "ci", "--legacy-peer-deps")
19+
sh("npm", "ci")
1020
# Special hack to work-around alpine linux problem - File.getCanonicalPath is failing without a reason:
1121
sh("find node_modules -name '*.gradle' -type f -exec sed -i.bak '/canonicalPath/d' {} +")
1222
end
1323
end
1424

15-
desc "Build development APK"
25+
desc "Build apk"
26+
lane :local do
27+
gradleOptions = {
28+
"android.injected.version.code" => BUILD_NUMBER.to_i() + versionCodeOffset,
29+
"android.injected.version.name" => "#{GOOGLE_PLAY_VERSION}.dev",
30+
}
31+
32+
gradle(task: "assemble", build_type: "Debug", flavor: "Production", flags: "--stacktrace", properties: gradleOptions)
33+
end
34+
35+
desc "Build apk and install in the simulator"
1636
lane :debug_internal do
37+
UI.message("Installing dependencies")
38+
gradleOptions = {
39+
"android.injected.version.code" => BUILD_NUMBER.to_i() + versionCodeOffset,
40+
"android.injected.version.name" => "#{GOOGLE_PLAY_VERSION}.dev",
41+
}
42+
43+
UI.message("Building DeveloperApp")
44+
gradle(task: "assemble", build_type: "Debug", flavor: "Production", flags: "--stacktrace", properties: gradleOptions)
45+
46+
# UI.message("Installing APK into Android device/simulator")
47+
# lane_context[SharedValues::GRADLE_ALL_APK_OUTPUT_PATHS].each do |apk|
48+
# begin
49+
# sh("adb reverse tcp:8080 tcp:8080")
50+
# sh("adb reverse tcp:8083 tcp:8083")
51+
# sh("adb install -r #{apk}")
52+
# end
53+
# end
54+
end
55+
56+
desc "Build new bundle and upload to Internal track"
57+
lane :internal do |options|
58+
FileUtils.copy(ORIGINAL_CHANGELOG_PATH, FASTLANE_CHANGELOG_PATH)
59+
versionCode = google_play_track_version_codes(track: "internal").max() + 1
60+
versionName = GOOGLE_PLAY_VERSION + "." + BUILD_NUMBER
61+
1762
gradleOptions = {
18-
"android.injected.version.code" => 1, # Static version code
19-
"android.injected.version.name" => "1.0.0.dev", # Static version name
63+
# Gradle 7.3 removed support for dynamic versioning through android.injected.version.code
64+
"versionCode" => versionCode,
65+
"versionName" => versionName,
66+
"android.injected.signing.store.file" => ENV["ANDROID_KEYSTORE_PATH"],
67+
"android.injected.signing.store.password" => ENV["ANDROID_KEYSTORE_PASSWORD"],
68+
"android.injected.signing.key.alias" => ENV["ANDROID_KEYSTORE_ALIAS"],
69+
"android.injected.signing.key.password" => ENV["ANDROID_KEYSTORE_KEY_PASSWORD"],
2070
}
2171

22-
gradle(
23-
task: "assemble",
24-
build_type: "Debug",
25-
flavor: "Production",
26-
flags: "--stacktrace",
27-
properties: gradleOptions
72+
UI.message "Replacing Firebase API keys from environment variables"
73+
Dir.chdir("../app") do
74+
firebaseApiKey = ENV["FIREBASE_API_KEY"] || "FIREBASE_API_KEY"
75+
sh("sed -i 's/{{firebase-api-key}}/#{firebaseApiKey}/g' google-services.json")
76+
end
77+
78+
if options[:submit] == true
79+
UI.message "Promoting version #{versionName} (#{versionCode}) to internal testing on Google PlayStore"
80+
#Build AAB
81+
gradle(
82+
task: "bundle",
83+
build_type: "Release",
84+
flavor: "Production",
85+
flags: "-x bundleRelease --stacktrace --no-daemon",
86+
print_command: false,
87+
properties: gradleOptions
88+
)
89+
90+
#Upload to Google Play (Internal track)
91+
supply(
92+
aab: lane_context[SharedValues::GRADLE_AAB_OUTPUT_PATH],
93+
track: "internal",
94+
skip_upload_images: true,
95+
skip_upload_apk: true,
96+
)
97+
else
98+
UI.message "Building APK version #{versionName}(#{versionCode}) for internal tests"
99+
#Build APK
100+
gradle(
101+
task: "assemble",
102+
build_type: "Release",
103+
flavor: "Production",
104+
flags: "-x assembleRelease --stacktrace",
105+
print_command: false,
106+
properties: gradleOptions
107+
)
108+
end
109+
end
110+
111+
desc "Promote last version of Internal track to Alpha"
112+
lane :promote_to_alpha do
113+
supply(
114+
track_promote_to: "alpha",
115+
track: "internal",
116+
version_code: google_play_track_version_codes(track: "internal").max(),
117+
rollout: "1",
118+
)
119+
end
120+
121+
desc "Promote the last version of Alpha track to Production (draft)"
122+
lane :promote_to_production do
123+
FileUtils.copy(ORIGINAL_CHANGELOG_PATH, FASTLANE_CHANGELOG_PATH)
124+
125+
supply(
126+
track_promote_to: "production",
127+
track: "internal",
128+
version_code: google_play_track_version_codes(track: "internal").max(),
129+
rollout: "1",
130+
)
131+
end
132+
133+
after_all do |lane, options|
134+
artifacts = []
135+
artifacts = artifacts.concat(lane_context[SharedValues::GRADLE_ALL_APK_OUTPUT_PATHS]) if lane_context[SharedValues::GRADLE_ALL_APK_OUTPUT_PATHS]
136+
artifacts = artifacts.concat(lane_context[SharedValues::GRADLE_ALL_AAB_OUTPUT_PATHS]) if lane_context[SharedValues::GRADLE_ALL_AAB_OUTPUT_PATHS]
137+
copy_artifacts(
138+
target_path: "../artifacts",
139+
artifacts: artifacts,
28140
)
29141
end
30142
end

maestro/tests/AppStartup.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ appId: "${APP_ID}"
1818
- takeScreenshot:
1919
path: "maestro/tests/images/actual/${PLATFORM}/MiN_page"
2020
- tapOn: "http://runtime-url:8080"
21-
- inputText: "http://localhost:8080"
21+
- inputText: "http://10.0.2.2:8080"
2222
- pressKey: Enter
2323
- hideKeyboard
2424
- takeScreenshot:

0 commit comments

Comments
 (0)