Skip to content

Commit

Permalink
feat(Android): create separate staging app (#552)
Browse files Browse the repository at this point in the history
  • Loading branch information
boringcactus authored Nov 22, 2024
1 parent 877d865 commit 234d817
Show file tree
Hide file tree
Showing 109 changed files with 81 additions and 10 deletions.
10 changes: 5 additions & 5 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -149,15 +149,15 @@ jobs:
MAPBOX_SECRET_TOKEN: ${{ secrets.MAPBOX_SECRET_TOKEN }}
MAPBOX_PUBLIC_TOKEN: ${{ secrets.MAPBOX_PUBLIC_TOKEN }}
run: |
bundle exec fastlane android build
bundle exec fastlane android build flavor:Prod
- uses: actions/upload-artifact@v4
with:
name: android-apk
path: androidApp/build/outputs/apk/release/androidApp-release.apk
path: androidApp/build/outputs/apk/prod/release/androidApp-prod-release.apk
- uses: actions/upload-artifact@v4
with:
name: android-aab
path: androidApp/build/outputs/bundle/release/androidApp-release.aab
path: androidApp/build/outputs/bundle/prodRelease/androidApp-prod-release.aab
deploy-android:
name: Upload to Google Play
if: github.event_name != 'pull_request'
Expand All @@ -177,12 +177,12 @@ jobs:
- uses: actions/download-artifact@v4
with:
name: android-aab
path: androidApp/build/outputs/bundle/release
path: androidApp/build/outputs/bundle/prodRelease
- uses: ./.github/actions/setup
with:
gcp-provider: ${{ secrets.GCP_WORKLOAD_IDENTITY_PROVIDER }}
gcp-service-account: ${{ secrets.GCP_SERVICE_ACCOUNT }}
ruby: true
- name: Upload to Google Play
run: |
bundle exec fastlane android internal
bundle exec fastlane android internal flavor:Prod
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,10 @@ ios app:
- Populate any configuration needed in your the .envrc file. These will be read by a build phase
script and set as info.plist values so that they can be read by the application.

### Android

To switch between the staging and prod app flavors, go to Build > Select Build Variant and then set the `:androidApp` Active Build Variant.

## Running Tests

### Unit Tests
Expand Down
9 changes: 9 additions & 0 deletions androidApp/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,15 @@ android {
buildFeatures { compose = true }
packaging { resources { excludes += "/META-INF/{AL2.0,LGPL2.1}" } }
buildTypes { getByName("release") { isMinifyEnabled = false } }
flavorDimensions += "environment"
productFlavors {
create("staging") {
dimension = "environment"
applicationIdSuffix = ".staging"
}

create("prod") { dimension = "environment" }
}
compileOptions {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
Expand Down
2 changes: 1 addition & 1 deletion androidApp/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
android:name=".MainApplication"
android:allowBackup="false"
android:icon="@mipmap/ic_launcher"
android:label="MBTA Transit"
android:label="MBTA Go"
android:networkSecurityConfig="@xml/network_security_config"
android:supportsRtl="true"
android:theme="@style/AppTheme">
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
package com.mbta.tid.mbta_app.android

import android.app.Application
import com.mbta.tid.mbta_app.AppVariant
import com.mbta.tid.mbta_app.android.phoenix.wrapped
import com.mbta.tid.mbta_app.android.util.decodeMessage
import com.mbta.tid.mbta_app.dependencyInjection.makeNativeModule
import com.mbta.tid.mbta_app.initKoin
import com.mbta.tid.mbta_app.repositories.AccessibilityStatusRepository
import org.phoenixframework.Socket

val appVariant = AppVariant.Prod
// unfortunately, expect/actual only works in multiplatform projects, so we can't
// expect val appVariant: AppVariant

class MainApplication : Application() {
private val socket = Socket(appVariant.socketUrl, decode = ::decodeMessage)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ fun drawableByName(name: String): Int =
"alert-small-silver-issue" -> R.drawable.alert_small_silver_issue
"alert-small-silver-shuttle" -> R.drawable.alert_small_silver_shuttle
"alert-small-silver-suspension" -> R.drawable.alert_small_silver_suspension
"empty-map-grid" -> R.drawable.empty_map_grid
"empty-search" -> R.drawable.empty_search
"fa-chevron-down" -> R.drawable.fa_chevron_down
"fa-chevron-left" -> R.drawable.fa_chevron_left
"fa-chevron-right" -> R.drawable.fa_chevron_right
Expand All @@ -69,6 +71,8 @@ fun drawableByName(name: String): Int =
"fa-clock" -> R.drawable.fa_clock
"fa-location-arrow-solid" -> R.drawable.fa_location_arrow_solid
"fa-magnifying-glass-solid" -> R.drawable.fa_magnifying_glass_solid
"fa-map" -> R.drawable.fa_map
"fa-phone" -> R.drawable.fa_phone
"fa-route" -> R.drawable.fa_route
"fa-xmark" -> R.drawable.fa_xmark
"live-data" -> R.drawable.live_data
Expand Down Expand Up @@ -129,13 +133,19 @@ fun drawableByName(name: String): Int =
"map-stop-wide-SILVER-terminal-746" -> R.drawable.map_stop_wide_silver_terminal_746
"map-stop-wide-SILVER-terminal-749" -> R.drawable.map_stop_wide_silver_terminal_749
"map-stop-wide-SILVER-terminal-751" -> R.drawable.map_stop_wide_silver_terminal_751
"mbta-logo" -> R.drawable.mbta_logo
"mode-bus" -> R.drawable.mode_bus
"mode-cr" -> R.drawable.mode_cr
"mode-ferry" -> R.drawable.mode_ferry
"mode-subway" -> R.drawable.mode_subway
"onboarding-halo" -> R.drawable.onboarding_halo
"onboarding-more-button" -> R.drawable.onboarding_more_button
"onboarding-transit-lines" -> R.drawable.onboarding_transit_lines
"pinned-route-active" -> R.drawable.pinned_route_active
"pinned-route-inactive" -> R.drawable.pinned_route_inactive
"t-logo" -> R.drawable.t_logo
"tab-icon-more" -> R.drawable.tab_icon_more
"tab-icon-nearby" -> R.drawable.tab_icon_nearby
"vehicle-halo" -> R.drawable.vehicle_halo
"vehicle-puck" -> R.drawable.vehicle_puck
else -> throw IllegalArgumentException("Invalid drawable name $name")
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added androidApp/src/main/res/drawable-hdpi/fa_map.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added androidApp/src/main/res/drawable-ldpi/fa_map.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added androidApp/src/main/res/drawable-mdpi/fa_map.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added androidApp/src/main/res/drawable-xhdpi/fa_map.png
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package com.mbta.tid.mbta_app.android

import com.mbta.tid.mbta_app.AppVariant

val appVariant = AppVariant.Prod
6 changes: 6 additions & 0 deletions androidApp/src/staging/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools">
<application
android:label="MBTA Go Staging"
tools:replace="android:label" />
</manifest>
Binary file added androidApp/src/staging/ic_launcher-playstore.png
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package com.mbta.tid.mbta_app.android

import com.mbta.tid.mbta_app.AppVariant

val appVariant = AppVariant.Staging
5 changes: 5 additions & 0 deletions androidApp/src/staging/res/mipmap-anydpi-v26/ic_launcher.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<background android:drawable="@mipmap/ic_launcher_background"/>
<foreground android:drawable="@mipmap/ic_launcher_foreground"/>
</adaptive-icon>
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<background android:drawable="@mipmap/ic_launcher_background"/>
<foreground android:drawable="@mipmap/ic_launcher_foreground"/>
</adaptive-icon>
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
1 change: 0 additions & 1 deletion fastlane/Appfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
for_platform :android do
json_key_data_raw("{}") # Not used by patched Fastlane, but required
package_name("com.mbta.tid.mbta_app")
end
25 changes: 24 additions & 1 deletion fastlane/Fastfile
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,17 @@ setup_ci if ENV['CI']
platform :android do
desc "Build an .apk and an .aab with an upcoming version code"
lane :build do |options|
package_name =
case options[:flavor]
when "Prod"
"com.mbta.tid.mbta_app"
when "Staging"
"com.mbta.tid.mbta_app.staging"
else
raise "Unknown flavor #{options[:flavor]}"
end
version_codes = google_play_track_version_codes(
package_name: package_name,
track: "internal",
)
last_version_code = version_codes.max
Expand All @@ -31,21 +41,34 @@ platform :android do
}
gradle(
task: 'assemble',
flavor: options[:flavor],
build_type: 'Release',
properties: properties
)
gradle(
task: 'bundle',
flavor: options[:flavor],
build_type: 'Release',
properties: properties
)
end

desc "Deploy a new version to Google Play for internal testing"
lane :internal do |options|
package_name =
case options[:flavor]
when "Prod"
"com.mbta.tid.mbta_app"
when "Staging"
"com.mbta.tid.mbta_app.staging"
else
raise "Unknown flavor #{options[:flavor]}"
end
flavor = options[:flavor].downcase
upload_to_play_store(
package_name: package_name,
track: "internal",
aab: "androidApp/build/outputs/bundle/release/androidApp-release.aab",
aab: "androidApp/build/outputs/bundle/#{flavor}Release/androidApp-#{flavor}-release.aab",
)
end
end

0 comments on commit 234d817

Please sign in to comment.