Skip to content

Commit 3b3241a

Browse files
renefloorxsahil03x
andauthored
chore(samples): build apk and upload to aws (#2266)
Co-authored-by: Sahil Kumar <[email protected]>
1 parent e612ab1 commit 3b3241a

File tree

4 files changed

+34
-14
lines changed

4 files changed

+34
-14
lines changed

.github/workflows/distribute_external.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -80,13 +80,13 @@ jobs:
8080
bundler-cache: true
8181
working-directory: sample_app/android
8282

83-
- name: Setup Firebase Service Account'
83+
- name: Distribute to S3
8484
working-directory: sample_app/android
85-
run: echo "${{ secrets.SAMPLE_FIREBASE_UPLOAD_CREDENTIALS }}" | base64 --decode | jq > ./firebase-service-account.json
86-
87-
- name: Distribute to Firebase
88-
working-directory: sample_app/android
89-
run: bundle exec fastlane distribute_to_firebase
85+
env:
86+
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
87+
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
88+
AWS_S3_BUCKET: ${{ secrets.AWS_S3_BUCKET }}
89+
run: bundle exec fastlane distribute_to_s3
9090

9191
ios:
9292
needs: determine_platforms

sample_app/android/app/build.gradle

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,12 @@ android {
8080
signingConfig signingConfigs.debug
8181
}
8282
}
83+
84+
applicationVariants.all { variant ->
85+
variant.outputs.all {
86+
outputFileName = "flutter-sample-app.apk"
87+
}
88+
}
8389
}
8490

8591
flutter {

sample_app/android/fastlane/Fastfile

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -45,20 +45,33 @@ platform :android do
4545
firebase_app_distribution(
4646
app: app_id,
4747
android_artifact_type: "APK",
48-
android_artifact_path: "#{root_path}/build/app/outputs/flutter-apk/app-release.apk",
48+
android_artifact_path: "#{root_path}/build/app/outputs/apk/release/flutter-sample-app.apk",
4949
groups: "stream-testers, ios-stream-testers",
5050
release_notes: "Lots of amazing new features to test out!",
5151
service_credentials_file: "#{root_path}/android/firebase-service-account.json"
5252
)
5353
end
5454

55-
private_lane :appstore_api_key do
56-
@appstore_api_key ||= app_store_connect_api_key(
57-
key_id: 'MT3PRT8TB7',
58-
issuer_id: '69a6de96-0738-47e3-e053-5b8c7c11a4d1',
59-
key_content: ENV.fetch('APPSTORE_API_KEY', nil),
60-
is_key_content_base64: true,
61-
in_house: false,
55+
desc "Build and distribute app to S3"
56+
# Usage: bundle exec fastlane android distribute_to_s3
57+
lane :distribute_to_s3 do |options|
58+
build_apk
59+
60+
bucket_with_path = ENV.fetch("AWS_S3_BUCKET")
61+
bucket_name, upload_path = bucket_with_path.chomp('/').split('/', 2)
62+
63+
# Validate that we have both bucket and path
64+
UI.user_error!("AWS_S3_BUCKET must include path (e.g., 'bucket-name/downloads')") if upload_path.nil? || upload_path.empty?
65+
66+
aws_s3(
67+
access_key: ENV.fetch("AWS_ACCESS_KEY_ID"),
68+
secret_access_key: ENV.fetch("AWS_SECRET_ACCESS_KEY"),
69+
region: ENV.fetch("AWS_REGION", "us-east-1"),
70+
bucket: bucket_name,
71+
path: upload_path,
72+
acl: "private",
73+
server_side_encryption: "AES256",
74+
files: ["#{root_path}/build/app/outputs/apk/release/flutter-sample-app.apk"]
6275
)
6376
end
6477
end

sample_app/android/fastlane/Pluginfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@
44

55
gem 'fastlane-plugin-stream_actions'
66
gem 'fastlane-plugin-firebase_app_distribution'
7+
gem 'fastlane-plugin-aws_s3'

0 commit comments

Comments
 (0)