diff --git a/.github/workflows/distribute_external.yml b/.github/workflows/distribute_external.yml index a0bf2a834..4f7e3b1c2 100644 --- a/.github/workflows/distribute_external.yml +++ b/.github/workflows/distribute_external.yml @@ -80,13 +80,13 @@ jobs: bundler-cache: true working-directory: sample_app/android - - name: Setup Firebase Service Account' + - name: Distribute to S3 working-directory: sample_app/android - run: echo "${{ secrets.SAMPLE_FIREBASE_UPLOAD_CREDENTIALS }}" | base64 --decode | jq > ./firebase-service-account.json - - - name: Distribute to Firebase - working-directory: sample_app/android - run: bundle exec fastlane distribute_to_firebase + env: + AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} + AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + AWS_S3_BUCKET: ${{ secrets.AWS_S3_BUCKET }} + run: bundle exec fastlane distribute_to_s3 ios: needs: determine_platforms diff --git a/sample_app/android/app/build.gradle b/sample_app/android/app/build.gradle index 7578a7020..37f245436 100644 --- a/sample_app/android/app/build.gradle +++ b/sample_app/android/app/build.gradle @@ -80,6 +80,12 @@ android { signingConfig signingConfigs.debug } } + + applicationVariants.all { variant -> + variant.outputs.all { + outputFileName = "flutter-sample-app.apk" + } + } } flutter { diff --git a/sample_app/android/fastlane/Fastfile b/sample_app/android/fastlane/Fastfile index 8f98fb993..8667caa3e 100644 --- a/sample_app/android/fastlane/Fastfile +++ b/sample_app/android/fastlane/Fastfile @@ -45,20 +45,33 @@ platform :android do firebase_app_distribution( app: app_id, android_artifact_type: "APK", - android_artifact_path: "#{root_path}/build/app/outputs/flutter-apk/app-release.apk", + android_artifact_path: "#{root_path}/build/app/outputs/apk/release/flutter-sample-app.apk", groups: "stream-testers, ios-stream-testers", release_notes: "Lots of amazing new features to test out!", service_credentials_file: "#{root_path}/android/firebase-service-account.json" ) end - private_lane :appstore_api_key do - @appstore_api_key ||= app_store_connect_api_key( - key_id: 'MT3PRT8TB7', - issuer_id: '69a6de96-0738-47e3-e053-5b8c7c11a4d1', - key_content: ENV.fetch('APPSTORE_API_KEY', nil), - is_key_content_base64: true, - in_house: false, + desc "Build and distribute app to S3" + # Usage: bundle exec fastlane android distribute_to_s3 + lane :distribute_to_s3 do |options| + build_apk + + bucket_with_path = ENV.fetch("AWS_S3_BUCKET") + bucket_name, upload_path = bucket_with_path.chomp('/').split('/', 2) + + # Validate that we have both bucket and path + UI.user_error!("AWS_S3_BUCKET must include path (e.g., 'bucket-name/downloads')") if upload_path.nil? || upload_path.empty? + + aws_s3( + access_key: ENV.fetch("AWS_ACCESS_KEY_ID"), + secret_access_key: ENV.fetch("AWS_SECRET_ACCESS_KEY"), + region: ENV.fetch("AWS_REGION", "us-east-1"), + bucket: bucket_name, + path: upload_path, + acl: "private", + server_side_encryption: "AES256", + files: ["#{root_path}/build/app/outputs/apk/release/flutter-sample-app.apk"] ) end end \ No newline at end of file diff --git a/sample_app/android/fastlane/Pluginfile b/sample_app/android/fastlane/Pluginfile index 75686ee9e..3b1aeb89e 100644 --- a/sample_app/android/fastlane/Pluginfile +++ b/sample_app/android/fastlane/Pluginfile @@ -4,3 +4,4 @@ gem 'fastlane-plugin-stream_actions' gem 'fastlane-plugin-firebase_app_distribution' +gem 'fastlane-plugin-aws_s3'