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+
47default_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+
616platform :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
30142end
0 commit comments