diff --git a/.github/workflows/publish.yaml b/.github/workflows/publish.yaml new file mode 100644 index 0000000..53bccb9 --- /dev/null +++ b/.github/workflows/publish.yaml @@ -0,0 +1,66 @@ +name: deploy + +on: + workflow_dispatch: + push: + branches: [master] + +jobs: + main: + runs-on: macos-latest + + steps: + - name: Clone repository + uses: actions/checkout@v4 + + - name: Set up Java + uses: actions/setup-java@v4 + with: + distribution: zulu + java-version: 21 + + - name: Set up Flutter + uses: subosito/flutter-action@v2 + with: + channel: stable + flutter-version-file: pubspec.yaml + + - name: Download pub dependencies + run: flutter pub get + + - name: Build Android app + run: flutter build apk --debug + + - name: Build iOS app + run: flutter build ios --debug --simulator + + - name: Upload iOS app to artifacts + uses: actions/upload-artifact@v4 + if: success() || failure() + with: + name: demo_app.apk + path: build/app/outputs/flutter-apk/demo_app.apk + retention-days: 1 + + - name: Upload iOS artifacts + uses: actions/upload-artifact@v4 + if: success() || failure() + with: + name: demo_app.app + path: build/ios/iphonesimulator/demo_app.app + retention-days: 1 + + - name: Authenticate to Google Cloud + uses: google-github-actions/auth@v2 + with: + # These credentials should only have write access to the bucket + credentials_json: ${{ secrets.GCP_MOBILEDEV_BUCKET_CREDENTIALS }} + + - name: Set up Google Cloud CLI + uses: google-github-actions/setup-gcloud@v2 + with: + version: ">= 484.0.0" + project_id: perf-dev-289002 + + - name: Upload apps to public Google Cloud Storage bucket + run: ./upload_to_gcs diff --git a/upload_to_gcs b/upload_to_gcs new file mode 100755 index 0000000..1dc5812 --- /dev/null +++ b/upload_to_gcs @@ -0,0 +1,25 @@ +#!/usr/bin/env sh +set -eu + +# Upload Android app +UPLOAD_PATH="gs://mobile.dev/cli_e2e" + +cd build/app/outputs/flutter-apk +cp app-debug.apk demo_app.apk +cd - + +gsutil cp build/app/outputs/flutter-apk/demo_app.apk "$UPLOAD_PATH/demo_app.apk" +gsutil acl ch -r -u AllUsers:R "$UPLOAD_PATH/demo_app.apk" + +# Upload iOS app +cd build/ios/iphonesimulator +cp Runner.app demo_app.app +cd demo_app.app + +zip -r -q ../demo_app.zip . -x "/**/.*" -x "__MACOSX" + +cd .. +cd ../../../ + +gsutil cp build/ios/iphonesimulator/demo_app.zip "$UPLOAD_PATH/demo_app.zip" +gsutil acl ch -r -u AllUsers:R "$UPLOAD_PATH/demo_app.zip"