Skip to content

Commit

Permalink
Update fastlane script to work with Play App Signing (#4986)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
lmac012 authored Sep 17, 2024
1 parent cb2d432 commit cd35320
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 23 deletions.
55 changes: 40 additions & 15 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,30 @@ android {
}
}
}
release
release {
def propertiesPath = "${CI_HOME_DIR}/ddg_android_build.properties"
def propertiesFile = new File(propertiesPath)
if (propertiesFile.exists()) {
def props = new Properties()
props.load(new FileInputStream(propertiesFile))
storeFile = file("${CI_HOME_DIR}/${props['key.store']}")
storePassword = props['key.store.password']
keyAlias = props['key.alias']
keyPassword = props['key.alias.password']
}
}
upload {
def propertiesPath = "${CI_HOME_DIR}/ddg_android_build_upload.properties"
def propertiesFile = new File(propertiesPath)
if (propertiesFile.exists()) {
def props = new Properties()
props.load(new FileInputStream(propertiesFile))
storeFile = file("${CI_HOME_DIR}/${props['key.store']}")
storePassword = props['key.store.password']
keyAlias = props['key.alias']
keyPassword = props['key.alias.password']
}
}
}
buildTypes {
debug {
Expand All @@ -102,11 +125,19 @@ android {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
signingConfig signingConfigs.release
manifestPlaceholders = [
appIcon : "@mipmap/ic_launcher_red",
appIconRound: "@mipmap/ic_launcher_red_round"
]

if (project.hasProperty('useUploadSigning')) {
signingConfig = signingConfigs.upload
} else if (isValidSigningConfig(signingConfigs.release)) {
signingConfig = signingConfigs.release
} else {
println "Signing properties not found, release artifacts will not be signed."
signingConfig = null
}
}
}
flavorDimensions "store"
Expand Down Expand Up @@ -137,20 +168,14 @@ android {
unitTests.returnDefaultValues = true
animationsDisabled = true
}
}

def propertiesPath = "${CI_HOME_DIR}/ddg_android_build.properties"
def propertiesFile = new File(propertiesPath)
if (propertiesFile.exists()) {
def props = new Properties()
props.load(new FileInputStream(propertiesFile))
android.signingConfigs.release.storeFile = file("${CI_HOME_DIR}/${props['key.store']}")
android.signingConfigs.release.storePassword = props['key.store.password']
android.signingConfigs.release.keyAlias = props['key.alias']
android.signingConfigs.release.keyPassword = props['key.alias.password']
} else {
println "Signing properties not found at ${propertiesPath}, releases will NOT succeed"
android.buildTypes.release.signingConfig = null
}
static def isValidSigningConfig(signingConfig) {
return signingConfig != null &&
signingConfig.storeFile?.exists() &&
signingConfig.storePassword &&
signingConfig.keyAlias &&
signingConfig.keyPassword
}

fulladleModuleConfig {
Expand Down
19 changes: 12 additions & 7 deletions fastlane/Fastfile
Original file line number Diff line number Diff line change
Expand Up @@ -52,18 +52,18 @@ platform :android do
end


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

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

update_fastlane_release_notes(release_number: flversion)

upload_to_play_store(
apk: apkPath,
aab: aabPath,
track: 'production',
rollout: '0.000001', # ie. 0.0001%
skip_upload_screenshots: true,
Expand Down Expand Up @@ -160,20 +160,20 @@ platform :android do

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

upload_to_play_store_internal_app_sharing(
apk: apkPath
aab: aabPath
)

end

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

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

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

download_universal_apk_from_google_play(
version_code: convert_version(release_number: version),
destination: apkPath
)

set_github_release(
repository_name: "DuckDuckGo/Android",
api_token: token,
Expand Down
2 changes: 1 addition & 1 deletion fastlane/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ For _fastlane_ installation instructions, see [Installing _fastlane_](https://do
[bundle exec] fastlane android deploy_playstore
```

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

### android update_release_notes_playstore

Expand Down

0 comments on commit cd35320

Please sign in to comment.