From be3e995c9e836f1219f93fdcb174ac870309a879 Mon Sep 17 00:00:00 2001
From: Markin Igor <markin.io210@gmail.com>
Date: Wed, 7 Aug 2019 18:08:45 +0500
Subject: [PATCH] Replace all scripts with Makefile

---
 Makefile         | 49 ++++++++++++++++++++++++++++++++++++++++++++++++
 build-android.sh | 21 ---------------------
 build-ios.sh     | 38 -------------------------------------
 run.sh           | 12 ------------
 4 files changed, 49 insertions(+), 71 deletions(-)
 create mode 100644 Makefile
 delete mode 100755 build-android.sh
 delete mode 100755 build-ios.sh
 delete mode 100755 run.sh

diff --git a/Makefile b/Makefile
new file mode 100644
index 0000000..d4a67bb
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,49 @@
+flavor=production
+entryPoint=main.dart
+
+iosBundleName=Vereign
+iosScheme=production
+iosConfiguration=Release-production
+
+
+ifeq ($(target), development)
+	flavor=development
+	entryPoint=main-dev.dart
+	iosBundleName=Vereign-dev
+    iosScheme=development
+    iosConfiguration=Release-development
+endif
+
+.PHONY: all build-ios build-android
+
+all: build-ios build-android
+
+run:
+	flutter run --flavor ${flavor} -t lib/${entryPoint}
+
+build-ios: flutter-build-ios archive-ios export-ios ## Builds ios bundle and upload to the AppStore
+
+build-android: ## Builds android bundle
+	flutter build apk --flavor ${flavor} -t lib/${entryPoint}
+
+flutter-build-ios: ## Performs flutter build
+	flutter build ios --flavor $(flavor) -t lib/$(entryPoint)
+
+archive-ios: ## Creates .xarchive from fullter build
+	xcodebuild \
+        -workspace ios/Runner.xcworkspace \
+        -scheme ${iosScheme} \
+        -sdk iphoneos \
+        -configuration ${iosConfiguration} \
+        archive -archivePath \
+        build/ios/$(iosBundleName).xcarchive
+
+export-ios: ## Exports ipa and uploads it to AppStore
+	xcodebuild \
+        -exportArchive \
+        -archivePath build/ios/${iosBundleName}.xcarchive \
+        -exportOptionsPlist ios/exportOptions-dev.plist \
+        -exportPath build/ios/${iosBundleName}
+
+clean: ## Removes build directory
+	flutter clean
\ No newline at end of file
diff --git a/build-android.sh b/build-android.sh
deleted file mode 100755
index 2d01da1..0000000
--- a/build-android.sh
+++ /dev/null
@@ -1,21 +0,0 @@
-#!/usr/bin/env bash
-
-flavor='production'
-entryPoint='main.dart'
-
-if [[ $1 == 'development' ]]
-then
-    flavor='development'
-    entryPoint='main-dev.dart'
-fi
-
-# Build android
-flutter build apk --flavor ${flavor} -t lib/${entryPoint}
-
-
-# Move packages wherever we need
-# cp build/app/outputs/apk/development/release/app-development-release.apk /path
-# cp build/app/outputs/apk/production/release/app-production-release.apk /path
-
-# Cleanup
-# flutter clean
diff --git a/build-ios.sh b/build-ios.sh
deleted file mode 100755
index 2109606..0000000
--- a/build-ios.sh
+++ /dev/null
@@ -1,38 +0,0 @@
-#!/usr/bin/env bash
-
-flavor='production'
-scheme='production'
-configuration='Release-production'
-entryPoint='main.dart'
-bundleName="Vereign"
-
-if [[ $1 == 'development' ]]
-then
-    flavor='development'
-    scheme='development'
-    configuration='Release-development'
-    entryPoint='main-dev.dart'
-    bundleName="Vereign-dev"
-fi
-
-# Build ios
-flutter build ios --flavor ${flavor} -t lib/${entryPoint}
-
-# Export xarchive
-xcodebuild \
-    -workspace ios/Runner.xcworkspace \
-    -scheme ${scheme} \
-    -sdk iphoneos \
-    -configuration ${configuration} \
-    archive -archivePath \
-    build/ios/${bundleName}.xcarchive
-
-# Package ipa
-xcodebuild \
-    -exportArchive \
-    -archivePath build/ios/${bundleName}.xcarchive \
-    -exportOptionsPlist ios/exportOptions-dev.plist \
-    -exportPath build/ios/${bundleName}
-
-# Cleanup
-# flutter clean
diff --git a/run.sh b/run.sh
deleted file mode 100755
index 6701ad5..0000000
--- a/run.sh
+++ /dev/null
@@ -1,12 +0,0 @@
-#!/usr/bin/env bash
-
-flavor='development'
-entryPoint='main-dev.dart'
-
-if [[ $1 == 'production' ]]
-then
-    flavor='production'
-    entryPoint='main.dart'
-fi
-
-flutter run --flavor ${flavor} -t lib/${entryPoint}
\ No newline at end of file
-- 
GitLab