-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
42 lines (33 loc) · 1.17 KB
/
Makefile
File metadata and controls
42 lines (33 loc) · 1.17 KB
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
# Makefile for deploying the Flutter web projects to GitHub
# from https://codewithandrea.com/articles/flutter-web-github-pages/
BASE_HREF = /$(OUTPUT)/
GITHUB_USER = devsticks
GITHUB_REPO = https://github.com/$(GITHUB_USER)/$(OUTPUT)
BUILD_VERSION := $(shell grep 'version:' pubspec.yaml | awk '{print $$2}')
# Deploy the Flutter web project to GitHub
deploy:
ifndef OUTPUT
$(error OUTPUT is not set. Usage: make deploy OUTPUT=<output_repo_name>)
endif
@echo "Clean existing repository"
flutter clean
@echo "Getting packages..."
flutter pub get
@echo "Generating the web folder..."
flutter create . --platform web
@echo "Building for web..."
flutter build web --base-href $(BASE_HREF) --release
@echo "Deploying to git repository"
cd build/web && \
echo "Current directory: $(shell pwd)" && \
echo "Listing files before Git operations:" && \
ls -la && \
git init && \
git checkout -b main && \
git add . && \
git commit -m "Deploy Version $(BUILD_VERSION)" && \
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/$(OUTPUT)/"
.PHONY: deploy