Skip to content

Instantly share code, notes, and snippets.

@Vanethos
Last active May 31, 2023 09:21
Show Gist options
  • Save Vanethos/0e2bf8ada6d1b01aed6cb9e8969b6fd9 to your computer and use it in GitHub Desktop.
Save Vanethos/0e2bf8ada6d1b01aed6cb9e8969b6fd9 to your computer and use it in GitHub Desktop.
Script to run Flutter Apps
#!/bin/bash
BLUE='\x1b[34m\x1b[1m'
NC='\x1b[0m' # No Color
echo ""
printf "${BLUE}[ πŸ—οΈ ] Build models${NC} \n"
cd modules/models
flutter packages pub run build_runner build --delete-conflicting-outputs
cd ../..
echo ""
printf "${BLUE}[ 🧹 ] Cleaning environment${NC} \n"
cd app
flutter clean
echo ""
printf "${BLUE}[ πŸ€– ] Preparing the Android App${NC} \n"
flutter build appbundle --flavor prod -t lib/main.dart
echo ""
printf "${BLUE}[ ➑️ ] Moving Android app to /exported${NC} \n"
cd ..
mkdir exported && mkdir exported/android
mv app/build/app/outputs/bundle/prodRelease/app.aab exported/android/app.aab
echo ""
printf "${BLUE}[ 🧹 ] Cleaning environment... Again${NC} \n"
cd app
flutter clean
echo ""
printf "${BLUE}[ 🍎 ] Preparing the iOS App${NC} \n"
cd ios
pod install
cd ..
flutter build ios --flavor prod -t lib/main.dart
echo ""
printf "${BLUE}[ 🏁 ] iOS App created! \n"
printf " To upload the app to TestFlight, open XCode and do the following: \n"
printf " 1. Product > Archive \n"
printf " 2. Window > Organizer (if a new window has not opened by default) \n"
printf " 3. Choose the latest Ianum App \n"
printf " 4. Click on Distribute \n"
printf " 5. Click Next or OK in the remaining screens \n"
printf " 6. Wait... Uploading the app to Apple's servers take a while, grab a coffee in the meantime β˜• \n"
echo ""
printf "[ πŸš€ ] Created both apps!! \n"
printf " - Follow the above instructions to deploy the iOS App \n"
printf " - For the Android App, go to /exported/android to find the appbundle\n${NC} "
#!/bin/bash
BLUE='\x1b[34m\x1b[1m'
GREEN='\x1b[32m\x1b[1m'
YELLOW='\x1b[33m'
RED='\x1b[31m\x1b[1m'
PURPLE='\x1b[35m\x1b[1m'
NC='\x1b[0m' # No Color
while getopts ":f:" opt; do
case $opt in
f)
FLAVOR=$OPTARG
;;
h)
echo "Flutter Distribute Tool"
echo "-f Flavor - dev, alpha or prod"
echo "-h Runs help"
;;
\?)
echo "Invalid option: -$OPTARG" >&2
echo "Flutter Run Tool"
echo "-f Flavor - dev, alpha or prod"
echo "-h Runs help"
exit 1
;;
esac
done
printf "${BLUE}Please write in the release notes (Press \"~\" when done):${NC}\n"
read -r -e -s -d "~" releaseNotes
echo "$releaseNotes" > "release-notes.txt"
echo ""
if [ -z "$FLAVOR" ]; then
printf "${BLUE} [ 🚧 ] Did not choose a flavor, building ${PURPLE}Dev ${NC} \n"
FLAVORFLAG="dev"
else
case "$FLAVOR" in
"dev")
printf "${BLUE} [ 🚧 ] Deploying ${PURPLE}Dev${BLUE} build ${NC} \n"
FLAVORFLAG="dev"
;;
"alpha")
printf "${BLUE} [ 🚧 ] Deploying ${PURPLE}Alpha${BLUE} build ${NC} \n"
FLAVORFLAG="alpha"
;;
"prod")
printf "${BLUE} [ 🚧 ] Deploying ${PURPLE}Prod${BLUE} build ${NC} \n"
FLAVORFLAG="prod"
;;
*)
printf "${RED} [ ⚠️ ] Invalid Flavor, going on with ${PURPLE}Dev${NC} \n"
FLAVORFLAG="dev"
;;
esac
fi
echo ""
printf "${BLUE}[ πŸ—οΈ ] Build models${NC}\n"
cd modules/models
flutter packages pub run build_runner build --delete-conflicting-outputs
cd ../..
echo ""
printf "${BLUE}[ 🧹 ] Cleaning environment${NC}\n"
cd app
flutter clean
echo ""
printf "${BLUE}[ πŸ€– ] Preparing the Android App${NC}\n"
cd android
fastlane $FLAVORFLAG
cd ..
echo ""
printf "${BLUE}[ 🧹 ] Cleaning environment... Again${NC}\n"
flutter clean
echo ""
printf "${BLUE}[ 🍎 ] Preparing the iOS App${NC}\n"
cd ios
pod install
fastlane $FLAVORFLAG
cd ..
printf "${GREEN}[ πŸš€ ] Released ${FLAVORFLAG^^} apps!${NC}\n"
#!/bin/bash
BLUE='\x1b[34m\x1b[1m'
YELLOW='\x1b[33m'
RED='\x1b[31m\x1b[1m'
PURPLE='\x1b[35m\x1b[1m'
NC='\x1b[0m' # No Color
cd app
echo ""
printf "${BLUE}[ ℹ️ ] Checking options... \n${NC}"
while getopts ":d:f:" opt; do
case $opt in
d)
DEVICE=$OPTARG
;;
f)
FLAVOR=$OPTARG
;;
h)
printf "${BLUE} Flutter Run Tool \n"
printf "-d Device id, can be copied from flutter --devices, if no argument, prints the devices \n"
printf "-f Flavor - dev, alpha or prod \n"
printf "-h Runs help ${NC} \n"
exit;
;;
\?)
printf "${RED} Invalid option${NC}"
printf "${BLUE} Flutter Run Tool \n"
printf "-d Device id, can be copied from flutter --devices, if no argument, prints the devices \n"
printf "-f Flavor - dev, alpha or prod \n"
printf "-h Runs help ${NC} \n"
exit;
;;
esac
done
if [ -z "$FLAVOR" ]; then
printf "${BLUE} [ 🚧 ] Did not choose a flavor, building ${PURPLE}Dev ${NC} \n"
FLAVORFLAG="-t lib/main_dev.dart --flavor dev"
else
case "$FLAVOR" in
"dev")
printf "${BLUE} [ 🚧 ] Deploying ${PURPLE}Dev${BLUE} build ${NC} \n"
FLAVORFLAG="-t lib/main_dev.dart --flavor dev"
;;
"alpha")
printf "${BLUE} [ 🚧 ] Deploying ${PURPLE}Alpha${BLUE} build ${NC} \n"
FLAVORFLAG="-t lib/main_alpha.dart --flavor alpha"
;;
"prod")
printf "${BLUE} [ 🚧 ] Deploying ${PURPLE}Prod${BLUE} build ${NC} \n"
FLAVORFLAG="-t lib/main.dart --flavor prod"
;;
*)
printf "${RED} [ ⚠️ ] Invalid Flavor, going on with ${PURPLE}Dev${NC} \n"
FLAVORFLAG="-t lib/main_dev.dart --flavor dev"
;;
esac
fi
if [ -z "$DEVICE" ]; then
printf "${BLUE} [ ℹ️ ] Did not choose a device\n"
printf " [ πŸ“± ] Available devices:\n${YELLOW}"
flutter devices
printf "${NC}"
else
DEVICEFLAG="-d $DEVICE"
printf "${BLUE} [ πŸ“± ] Chose Device devices: ${YELLOW}${DEVICE}\n${NC}"
fi
echo ""
# Run Flutter app
printf "${BLUE}[ πŸƒβ€β™€οΈ ] Running the app\n${NC}"
echo ""
flutter run $FLAVORFLAG $DEVICEFLAG
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment