From f13065bbe9a9ed46e4fb1d4053cf52840c7883fd Mon Sep 17 00:00:00 2001 From: Rene Floor Date: Tue, 27 May 2025 11:20:22 +0200 Subject: [PATCH 1/2] chore: build apk and upload to aws --- .github/workflows/distribute_external.yml | 28 +++++++++++++++-------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/.github/workflows/distribute_external.yml b/.github/workflows/distribute_external.yml index a0bf2a834..a1c72c156 100644 --- a/.github/workflows/distribute_external.yml +++ b/.github/workflows/distribute_external.yml @@ -74,19 +74,27 @@ jobs: cache: true cache-key: flutter-:os:-:channel:-:version:-:arch:-:hash:-${{ hashFiles('**/pubspec.lock') }} - - name: Setup Ruby - uses: ruby/setup-ruby@v1 + - name: Build + run: flutter build apk + working-directory: sample_app + + - name: Upload Artifact + uses: actions/upload-artifact@v4 with: - bundler-cache: true - working-directory: sample_app/android + name: android-stream-chat-v1 + path: sample_app/build/app/outputs/apk/release/app-release.apk - - name: Setup Firebase Service Account' - working-directory: sample_app/android - run: echo "${{ secrets.SAMPLE_FIREBASE_UPLOAD_CREDENTIALS }}" | base64 --decode | jq > ./firebase-service-account.json + - name: Configure AWS credentials + uses: aws-actions/configure-aws-credentials@v2 + with: + aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} + aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + aws-region: us-east-1 - - name: Distribute to Firebase - working-directory: sample_app/android - run: bundle exec fastlane distribute_to_firebase + - name: Upload to S3 + run: | + cp sample_app/build/app/outputs/apk/release/app-release.apk flutter-sample-app.apk + aws s3 cp flutter-sample-app.apk s3://${{ secrets.AWS_S3_BUCKET }} --sse AES256 ios: needs: determine_platforms From fb8822be7f1c8d8332e81a805194c17cfc342f51 Mon Sep 17 00:00:00 2001 From: Sahil Kumar Date: Fri, 30 May 2025 19:33:54 +0200 Subject: [PATCH 2/2] refactor: move to fastlane --- .github/workflows/distribute_external.yml | 30 +++++++++-------------- sample_app/android/app/build.gradle | 6 +++++ sample_app/android/fastlane/Fastfile | 29 ++++++++++++++++------ sample_app/android/fastlane/Pluginfile | 1 + 4 files changed, 39 insertions(+), 27 deletions(-) diff --git a/.github/workflows/distribute_external.yml b/.github/workflows/distribute_external.yml index a1c72c156..4f7e3b1c2 100644 --- a/.github/workflows/distribute_external.yml +++ b/.github/workflows/distribute_external.yml @@ -74,27 +74,19 @@ jobs: cache: true cache-key: flutter-:os:-:channel:-:version:-:arch:-:hash:-${{ hashFiles('**/pubspec.lock') }} - - name: Build - run: flutter build apk - working-directory: sample_app - - - name: Upload Artifact - uses: actions/upload-artifact@v4 - with: - name: android-stream-chat-v1 - path: sample_app/build/app/outputs/apk/release/app-release.apk - - - name: Configure AWS credentials - uses: aws-actions/configure-aws-credentials@v2 + - name: Setup Ruby + uses: ruby/setup-ruby@v1 with: - aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} - aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} - aws-region: us-east-1 + bundler-cache: true + working-directory: sample_app/android - - name: Upload to S3 - run: | - cp sample_app/build/app/outputs/apk/release/app-release.apk flutter-sample-app.apk - aws s3 cp flutter-sample-app.apk s3://${{ secrets.AWS_S3_BUCKET }} --sse AES256 + - name: Distribute to S3 + working-directory: sample_app/android + 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'