-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
85 lines (66 loc) · 2.26 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
# Makefile for deploying the Flutter web projects to GitHub
BASE_HREF = /$(NAME)/
# Replace with your GitHub username
GITHUB_USER = DmitriyKulagin
GITHUB_REPO = https://github.com/$(GITHUB_USER)/$(NAME)
BUILD_VERSION := $(if $(NAME),$(shell grep 'version:' $(NAME)/pubspec.yaml | awk '{print $$2}'))
# Deploy the Flutter web project to GitHub
deploy:
ifndef NAME
$(error NAME is not set. Usage: make deploy NAME=<name>)
endif
@echo "Clean existing repository"
cd $(NAME) && flutter clean
@echo "Getting packages..."
cd $(NAME) && flutter pub get
@echo "Generating the web folder..."
cd $(NAME) && flutter create . --platform web
@echo "Building for web..."
cd $(NAME) && flutter build web --base-href $(BASE_HREF) --release
@echo "Deploying to git repository"
cd $(NAME)/build/web && \
git init && \
git add . && \
git commit -m "Deploy Version $(BUILD_VERSION)" && \
git branch -M main && \
git remote add origin $(GITHUB_REPO) && \
git push -u -f origin main
@echo "✅ Finished deploy: $(GITHUB_REPO)"
@echo "🚀 Flutter web URL: https://$(GITHUB_USER).github.io/$(NAME)/"
## Archive the project as a zip file
zip:
ifndef NAME
$(error NAME is not set. Usage: make zip NAME=<name>)
endif
@echo "Clean existing repository"
cd $(NAME) && flutter clean && rm -rf .idea android ios linux macos windows web test *.iml || true
@echo "Creating zipped project"
rm $(NAME).zip || true && zip -r $(NAME).zip $(NAME)
## Create new Flutter project and copy all the files from the template
create:
ifndef NAME
$(error NAME is not set. Usage: make create NAME=<name>)
endif
@echo "Creating new Flutter project..."
flutter create -e $(NAME)
@echo "Copying files from the template..."
cp -r template/.vscode $(NAME)
cp template/.gitignore $(NAME)
cp template/CHANGELOG.md $(NAME)
cp template/LICENSE.md $(NAME)
cp template/README.md $(NAME)
@echo "Getting packages..."
cd $(NAME) && flutter pub get
@echo "✅ Finished creating new project: $(NAME)"
## Prepare for development
dev:
ifndef NAME
$(error NAME is not set. Usage: make dev NAME=<name>)
endif
@echo "Getting packages..."
cd $(NAME) && flutter pub get
@echo "Generating the platform folders..."
cd $(NAME) && flutter create .
@echo "Deleting the test folder..."
cd $(NAME) && rm -rf test || true
.PHONY: deploy