Skip to content

Commit

Permalink
add action to automatically update artifacts in GCS bucket
Browse files Browse the repository at this point in the history
  • Loading branch information
bartekpacia committed Sep 4, 2024
1 parent b052cfd commit fb6389b
Show file tree
Hide file tree
Showing 2 changed files with 91 additions and 0 deletions.
66 changes: 66 additions & 0 deletions .github/workflows/publish.yaml
Original file line number Diff line number Diff line change
@@ -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
25 changes: 25 additions & 0 deletions upload_to_gcs
Original file line number Diff line number Diff line change
@@ -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"

0 comments on commit fb6389b

Please sign in to comment.