Skip to content

Commit cd35320

Browse files
authored
Update fastlane script to work with Play App Signing (#4986)
Task/Issue URL: https://app.asana.com/0/1202552961248957/1208202742960277/f ### Description This PR updates fastlane script to use App Bundle format when uploading app to the Play Store ### Steps to test this PR QA-Optional ### No UI changes
1 parent cb2d432 commit cd35320

File tree

3 files changed

+53
-23
lines changed

3 files changed

+53
-23
lines changed

app/build.gradle

Lines changed: 40 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,30 @@ android {
8888
}
8989
}
9090
}
91-
release
91+
release {
92+
def propertiesPath = "${CI_HOME_DIR}/ddg_android_build.properties"
93+
def propertiesFile = new File(propertiesPath)
94+
if (propertiesFile.exists()) {
95+
def props = new Properties()
96+
props.load(new FileInputStream(propertiesFile))
97+
storeFile = file("${CI_HOME_DIR}/${props['key.store']}")
98+
storePassword = props['key.store.password']
99+
keyAlias = props['key.alias']
100+
keyPassword = props['key.alias.password']
101+
}
102+
}
103+
upload {
104+
def propertiesPath = "${CI_HOME_DIR}/ddg_android_build_upload.properties"
105+
def propertiesFile = new File(propertiesPath)
106+
if (propertiesFile.exists()) {
107+
def props = new Properties()
108+
props.load(new FileInputStream(propertiesFile))
109+
storeFile = file("${CI_HOME_DIR}/${props['key.store']}")
110+
storePassword = props['key.store.password']
111+
keyAlias = props['key.alias']
112+
keyPassword = props['key.alias.password']
113+
}
114+
}
92115
}
93116
buildTypes {
94117
debug {
@@ -102,11 +125,19 @@ android {
102125
release {
103126
minifyEnabled false
104127
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
105-
signingConfig signingConfigs.release
106128
manifestPlaceholders = [
107129
appIcon : "@mipmap/ic_launcher_red",
108130
appIconRound: "@mipmap/ic_launcher_red_round"
109131
]
132+
133+
if (project.hasProperty('useUploadSigning')) {
134+
signingConfig = signingConfigs.upload
135+
} else if (isValidSigningConfig(signingConfigs.release)) {
136+
signingConfig = signingConfigs.release
137+
} else {
138+
println "Signing properties not found, release artifacts will not be signed."
139+
signingConfig = null
140+
}
110141
}
111142
}
112143
flavorDimensions "store"
@@ -137,20 +168,14 @@ android {
137168
unitTests.returnDefaultValues = true
138169
animationsDisabled = true
139170
}
171+
}
140172

141-
def propertiesPath = "${CI_HOME_DIR}/ddg_android_build.properties"
142-
def propertiesFile = new File(propertiesPath)
143-
if (propertiesFile.exists()) {
144-
def props = new Properties()
145-
props.load(new FileInputStream(propertiesFile))
146-
android.signingConfigs.release.storeFile = file("${CI_HOME_DIR}/${props['key.store']}")
147-
android.signingConfigs.release.storePassword = props['key.store.password']
148-
android.signingConfigs.release.keyAlias = props['key.alias']
149-
android.signingConfigs.release.keyPassword = props['key.alias.password']
150-
} else {
151-
println "Signing properties not found at ${propertiesPath}, releases will NOT succeed"
152-
android.buildTypes.release.signingConfig = null
153-
}
173+
static def isValidSigningConfig(signingConfig) {
174+
return signingConfig != null &&
175+
signingConfig.storeFile?.exists() &&
176+
signingConfig.storePassword &&
177+
signingConfig.keyAlias &&
178+
signingConfig.keyPassword
154179
}
155180

156181
fulladleModuleConfig {

fastlane/Fastfile

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -52,18 +52,18 @@ platform :android do
5252
end
5353

5454

55-
desc "Upload APK to Play Store, in production track with a very small rollout percentage"
55+
desc "Upload AAB to Play Store, in production track with a very small rollout percentage"
5656
lane :deploy_playstore do
5757

5858
props = property_file_read(file: "app/version/version.properties")
5959
version = props["VERSION"]
6060
flversion = convert_version(release_number: version)
61-
apkPath = "app/build/outputs/apk/play/release/duckduckgo-#{version}-play-release.apk"
61+
aabPath = "app/build/outputs/bundle/playRelease/duckduckgo-#{version}-play-release.aab"
6262

6363
update_fastlane_release_notes(release_number: flversion)
6464

6565
upload_to_play_store(
66-
apk: apkPath,
66+
aab: aabPath,
6767
track: 'production',
6868
rollout: '0.000001', # ie. 0.0001%
6969
skip_upload_screenshots: true,
@@ -160,20 +160,20 @@ platform :android do
160160

161161
props = property_file_read(file: "app/version/version.properties")
162162
version = props["VERSION"]
163-
apkPath = "app/build/outputs/apk/play/release/duckduckgo-#{version}-play-release.apk"
163+
aabPath = "app/build/outputs/bundle/playRelease/duckduckgo-#{version}-play-release.aab"
164164

165165
upload_to_play_store_internal_app_sharing(
166-
apk: apkPath
166+
aab: aabPath
167167
)
168168

169169
end
170170

171171
desc "Upload APK to Play Store internal testing track"
172172
lane :deploy_dogfood do |options|
173173

174-
UI.message("Apk path: #{options[:apk_path]}")
174+
UI.message("Aab path: #{options[:aab_path]}")
175175
upload_to_play_store(
176-
apk: options[:apk_path],
176+
aab: options[:aab_path],
177177
track: 'internal',
178178
skip_upload_screenshots: true,
179179
skip_upload_images: true,
@@ -193,6 +193,11 @@ platform :android do
193193

194194
UI.message ("Upload new app version to GitHub\nVersion: #{version}\nRelease Notes:\n=====\n#{releaseNotes}\n=====\n")
195195

196+
download_universal_apk_from_google_play(
197+
version_code: convert_version(release_number: version),
198+
destination: apkPath
199+
)
200+
196201
set_github_release(
197202
repository_name: "DuckDuckGo/Android",
198203
api_token: token,

fastlane/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ For _fastlane_ installation instructions, see [Installing _fastlane_](https://do
2121
[bundle exec] fastlane android deploy_playstore
2222
```
2323

24-
Upload APK to Play Store, in production track with a very small rollout percentage
24+
Upload AAB to Play Store, in production track with a very small rollout percentage
2525

2626
### android update_release_notes_playstore
2727

0 commit comments

Comments
 (0)