-
Notifications
You must be signed in to change notification settings - Fork 213
/
Copy pathMakefile
213 lines (169 loc) · 5.98 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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
# Define common variables
FLAVOR := family
FASTLANE := fastlane
VERSION_SCRIPT := ./scripts/version.py
ANDROID_PROJECT_FILE := android/app/build.gradle
IOS_PROJECT_FILE := ios/IOS.xcodeproj/project.pbxproj
CI_BUILD_DIR := /tmp/build
# Default target
.DEFAULT_GOAL := build
.PHONY: clean test build \
build-android build-android-family build-android-six \
build-ios build-ios-family build-ios-six \
version version-clean \
publish-android gplay-key-unpack gplay-key-clean \
publish-ios appstore-key-unpack appstore-key-clean \
build-android-family-debug build-android-six-debug \
rebuild android rebuild-android rebuild-ios \
install-family install-family-debug \
install-six install-six-debug uninstall \
ci-copy-source \
ci-build-android-family ci-build-android-six \
ci-build-ios-family ci-build-ios-six \
clean:
$(MAKE) gplay-key-clean
$(MAKE) appstore-key-clean
$(MAKE) -C common/ clean
$(MAKE) -C android/ clean
test:
$(MAKE) -C common/ pub gen-android runner
$(MAKE) -C common/ test
# Build everything from scratch
build:
$(MAKE) -C common/ build
$(MAKE) -C android/ build
$(MAKE) -C ios/ build
# Build all android .aab apps from scratch (release)
build-android:
$(MAKE) -C common/ build-android
$(MAKE) -C android/ build
# Build android family .aab from scratch (release)
build-android-family:
$(MAKE) -C common/ build-android
$(MAKE) -C android/ aab-family
# Build android six .aab from scratch (release)
build-android-six:
$(MAKE) -C common/ build-android
$(MAKE) -C android/ aab-six
# Build all ios .ipa apps from scratch (release)
build-ios:
$(MAKE) -C common/ build-ios
$(MAKE) -C ios/ build
# Build ios family .ipa from scratch (release)
build-ios-family:
$(MAKE) -C common/ build-ios
$(MAKE) -C ios/ build-family
# Build ios six .ipa from scratch (release)
build-ios-six:
$(MAKE) -C common/ build-ios
$(MAKE) -C ios/ build-six
# Set version in proper files for all apps (use NAME and CODE params, or env vars)
version:
@VERSION_NAME_ARG=$(if $(NAME),$(NAME),$(BLOKADA_VERSION_NAME)); \
VERSION_CODE_ARG=$(if $(CODE),$(CODE),$(BLOKADA_VERSION_CODE)); \
$(VERSION_SCRIPT) --android-file $(ANDROID_PROJECT_FILE) \
--xcodeproj-file $(IOS_PROJECT_FILE) \
--version-name $$VERSION_NAME_ARG \
--version-code $$VERSION_CODE_ARG
# Restore files changed with version numbers
version-clean:
git restore $(ANDROID_PROJECT_FILE)
git restore $(IOS_PROJECT_FILE)
# Publish android app to Google Play internal channel (use FLAVOR param)
publish-android:
$(MAKE) gplay-key-unpack
@AAB=$(if $(filter family,$(FLAVOR)),familyRelease/app-family-release.aab,sixRelease/app-six-release.aab); \
PKG=$(if $(filter family,$(FLAVOR)),org.blokada.family,org.blokada.sex); \
$(FASTLANE) supply --aab android/app/build/outputs/bundle/$$AAB \
--package_name "$$PKG" \
--json_key blokada-gplay.json \
--metadata_path metadata/android-$(FLAVOR) \
--track internal
$(MAKE) gplay-key-clean
# Unpack Google Play api key for publishing (use env var)
gplay-key-unpack:
@if [ -z "$$BLOKADA_GPLAY_KEY_BASE64" ]; then \
echo "Error: BLOKADA_GPLAY_KEY_BASE64 is not set. Please export it before running this command."; \
exit 1; \
fi
@echo "$$BLOKADA_GPLAY_KEY_BASE64" | base64 --decode > blokada-gplay.json
# Clean up after unpacking Google Play key
gplay-key-clean:
rm -rf blokada-gplay.json
# Publish ios app to AppStore TestFlight (use FLAVOR param)
publish-ios:
$(MAKE) appstore-key-unpack
@LANE=$(if $(filter family,$(FLAVOR)),publish_ios_family,publish_ios_six); \
cd ios/ && $(FASTLANE) $$LANE
$(MAKE) appstore-key-clean
# Unpack AppStore api key for publishing (use env var)
appstore-key-unpack:
@if [ -z "$$BLOKADA_APPSTORE_KEY_BASE64" ]; then \
echo "Error: BLOKADA_APPSTORE_KEY_BASE64 is not set. Please export it before running this command."; \
exit 1; \
fi
@echo "$$BLOKADA_APPSTORE_KEY_BASE64" | base64 --decode > ios/blokada-appstore.json
# Clean up after unpacking AppStore key
appstore-key-clean:
rm -rf ios/blokada-appstore.json
# Build android family .apk from scratch (debug)
build-android-family-debug: rebuild-android
$(MAKE) -C android/ apk-family-debug
# Build android six .apk from scratch (debug)
build-android-six-debug: rebuild-android
$(MAKE) -C android/ apk-six-debug
# Prepare flutter gen files
regen:
$(MAKE) -C common/ gen
# Clean everything and rebuild flutter gen files
rebuild:
$(MAKE) clean
$(MAKE) -C common/ pub gen
# Rebuild flutter android common lib - no dependencies (debug)
android:
$(MAKE) -C common/ lib-debug
# Clean everything and rebuild flutter android common lib (debug)
rebuild-android:
$(MAKE) -C common/ pub gen-android runner lib-debug
# Clean everything and rebuild flutter ios dependencies
rebuild-ios:
$(MAKE) -C common/ build-ios
# Install android family .apk (release)
install-family:
$(MAKE) -C android/ install-family
# Install android family .apk (debug)
install-family-debug:
$(MAKE) -C android/ install-family-debug
# Install android six .apk (release)
install-six:
$(MAKE) -C android/ install-six
# Install android six .apk (debug)
install-six-debug:
$(MAKE) -C android/ install-six-debug
# Uninstall all Android apps
uninstall:
$(MAKE) -C android/ uninstall
# CI: Copy the workspace out of volume to prevent weird filesystem issues
ci-copy-source:
@echo "Copying source files to $(CI_BUILD_DIR)..."
@rm -rf $(CI_BUILD_DIR)
@mkdir -p $(CI_BUILD_DIR)
@cp -r . $(CI_BUILD_DIR)
# CI: build android family app from scratch
ci-build-android-family: ci-copy-source
cd $(CI_BUILD_DIR) && $(MAKE) version
cd $(CI_BUILD_DIR) && $(MAKE) build-android-family
cp -r $(CI_BUILD_DIR)/android/app/build ./android/app/
# CI: build android six app from scratch
ci-build-android-six: ci-copy-source
cd $(CI_BUILD_DIR) && $(MAKE) version
cd $(CI_BUILD_DIR) && $(MAKE) build-android-six
cp -r $(CI_BUILD_DIR)/android/app/build ./android/app/
# CI: build ios family app from scratch
ci-build-ios-family:
$(MAKE) version
$(MAKE) build-ios-family
# CI: build ios six app from scratch
ci-build-ios-six:
$(MAKE) version
$(MAKE) build-ios-six