1#!/bin/bash 2 3set -e 4 5function script_location() { 6 local script_location="${BASH_SOURCE[0]}" 7 # Resolve symlinks 8 while [[ -h "$script_location" ]]; do 9 DIR="$(cd -P "$(dirname "$script_location")" >/dev/null && pwd)" 10 script_location="$(readlink "$script_location")" 11 [[ "$script_location" != /* ]] && script_location="$DIR/$script_location" 12 done 13 echo "$(cd -P "$(dirname "$script_location")" >/dev/null && pwd)" 14} 15 16# So that users can run this script locally from any directory and it will work as 17# expected. 18SCRIPT_LOCATION="$(script_location)" 19FLUTTER_ROOT="$(dirname "$(dirname "$SCRIPT_LOCATION")")" 20 21export PATH="$FLUTTER_ROOT/bin:$FLUTTER_ROOT/bin/cache/dart-sdk/bin:$PATH" 22 23set -x 24 25cd "$FLUTTER_ROOT" 26 27if [[ "$SHARD" = "deploy_gallery" ]]; then 28 version="$(<version)" 29 if [[ "$OS" == "linux" ]]; then 30 echo "Building Flutter Gallery $version for Android..." 31 32 # ANDROID_SDK_ROOT must be set in the env. 33 ( 34 cd examples/flutter_gallery 35 flutter build apk --release -t lib/main_publish.dart 36 ) 37 echo "Android Flutter Gallery built" 38 if [[ -z "$CIRRUS_PR" && "$CIRRUS_BRANCH" == "dev" && "$version" != *"pre"* ]]; then 39 echo "Deploying Flutter Gallery $version to Play Store..." 40 set +x # Don't echo back the below. 41 if [ -n "$ANDROID_GALLERY_UPLOAD_KEY" ]; then 42 echo "$ANDROID_GALLERY_UPLOAD_KEY" | base64 --decode > /root/.android/debug.keystore 43 fi 44 set -x 45 ( 46 cd examples/flutter_gallery/android 47 fastlane deploy_play_store 48 ) 49 else 50 echo "Not deployed: Flutter Gallery is only deployed to the Play Store on merged and tagged dev branch commits" 51 fi 52 elif [[ "$OS" == "darwin" ]]; then 53 echo "Building Flutter Gallery $version for iOS..." 54 ( 55 cd examples/flutter_gallery 56 flutter build ios --release --no-codesign -t lib/main_publish.dart 57 ) 58 echo "iOS Flutter Gallery built" 59 if [[ -z "$CIRRUS_PR" ]]; then 60 if [[ "$CIRRUS_BRANCH" == "dev" && "$version" != *"pre"* ]]; then 61 echo "Archiving with distribution profile and deploying to TestFlight..." 62 ( 63 cd examples/flutter_gallery/ios 64 export DELIVER_ITMSTRANSPORTER_ADDITIONAL_UPLOAD_PARAMETERS="-t DAV" 65 fastlane build_and_deploy_testflight upload:true 66 ) 67 else 68 echo "Archiving with distribution profile..." 69 ( 70 cd examples/flutter_gallery/ios 71 fastlane build_and_deploy_testflight 72 ) 73 echo "Archive is only deployed to TestFlight on tagged dev branch commits" 74 fi 75 else 76 echo "Not deployed: Flutter Gallery is only deployed to TestFlight on merged and tagged dev branch commits" 77 fi 78 fi 79else 80 echo "Doing nothing: not on the 'deploy_gallery' SHARD." 81fi 82