Last active
May 31, 2023 09:21
-
-
Save Vanethos/0e2bf8ada6d1b01aed6cb9e8969b6fd9 to your computer and use it in GitHub Desktop.
Script to run Flutter Apps
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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} " |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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