DEV Community

Cover image for Flutter๐ŸฌJust One Command to Deploy to both Android and iOS
Kaede Games ๐ŸŽฎ
Kaede Games ๐ŸŽฎ

Posted on

Flutter๐ŸฌJust One Command to Deploy to both Android and iOS

Automation Tasks

  1. Increment of build number and version number
  2. Build and deploy to iOS
  3. Build and deploy to Android

So, letโ€™s get started!

Make .env

ANDROID_UPLOAD_LINK: https://~~~
Enter fullscreen mode Exit fullscreen mode

Make deploy.sh

#!/bin/bash

iosDeploy() {
  echo "๐ŸŽ iOS build started ๐Ÿš€๐Ÿš€๐Ÿš€"
  flutter build ipa --release --export-options-plist=ExportOptions.plist
  echo "๐ŸŽ iOS build finished ๐ŸŽ‰๐ŸŽ‰๐ŸŽ‰"
}

androidDeploy() {
  echo "๐Ÿ Android build started ๐Ÿš€๐Ÿš€๐Ÿš€"
  flutter build appbundle
  open -R ./build/app/outputs/bundle/release/app-release.aab
  open $ANDROID_UPLOAD_LINK
  echo "๐Ÿ Android build finished ๐ŸŽ‰๐ŸŽ‰๐ŸŽ‰"
}


# Increment version
perl -i -pe 's/^(version:\s+\d+\.\d+\.\d+\+)(\d+)$/$1.($2+1)/e' pubspec.yaml

source .env
# Deploy
iosDeploy &
androidDeploy &

wait
echo "Both builds finished ๐ŸŽ‰๐ŸŽ‰๐ŸŽ‰"
Enter fullscreen mode Exit fullscreen mode

Grant executive authority to deploy.sh

chmod +x deploy.sh
Enter fullscreen mode Exit fullscreen mode

Try the command! ๐Ÿฆ„

./deploy.sh
Enter fullscreen mode Exit fullscreen mode

SAYONARA

Top comments (0)