forked from kickstarter/ios-oss
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
193 lines (156 loc) · 5.47 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
XCODEBUILD := xcodebuild
BUILD_FLAGS = -scheme $(SCHEME) -destination $(DESTINATION)
SCHEME ?= $(TARGET)-$(PLATFORM)
TARGET ?= Kickstarter-Framework
PLATFORM ?= iOS
RELEASE ?= beta
IOS_VERSION ?= 12.0
IPHONE_NAME ?= iPhone 8
BRANCH ?= master
DIST_BRANCH = $(RELEASE)-dist
OPENTOK_VERSION ?= 2.10.2
FABRIC_SDK_VERSION ?= 3.10.5
STRIPE_SDK_VERSION ?= 13.2.0
COMMIT ?= $(CIRCLE_SHA1)
ifeq ($(PLATFORM),iOS)
DESTINATION ?= 'platform=iOS Simulator,name=$(IPHONE_NAME),OS=$(IOS_VERSION)'
endif
XCPRETTY :=
ifneq ($(CIRCLE_ARTIFACTS),)
XCPRETTY += | tee $${CIRCLE_ARTIFACTS}/xcode_raw_$(SCHEME).log
endif
ifneq ($(shell type -p xcpretty),)
XCPRETTY += | xcpretty -c && exit $${PIPESTATUS[0]}
endif
build: dependencies
$(XCODEBUILD) $(BUILD_FLAGS) $(XCPRETTY)
test-all:
PLATFORM=iOS "$(MAKE)" test
PLATFORM=iOS TARGET=Library "$(MAKE)" test
test: bootstrap
$(XCODEBUILD) test $(BUILD_FLAGS) $(XCPRETTY)
clean:
$(XCODEBUILD) clean $(BUILD_FLAGS) $(XCPRETTY)
dependencies: submodules configs secrets opentok fabric stripe
bootstrap: hooks dependencies
brew update || brew update
brew unlink swiftlint || true
brew install swiftlint
brew link --overwrite swiftlint
submodules:
git submodule sync --recursive || true
git submodule update --init --recursive || true
configs = $(basename $(wildcard Kickstarter-iOS/Configs/*.example))
$(configs):
cp [email protected] $@
configs: $(configs)
hooks = $(addprefix .git/,$(wildcard hooks/*))
$(hooks):
@test -d .git/hooks && ln -fnsv $(patsubst .git/%,$(PWD)/%,$@) $@ \
|| echo "skipping git hook installation: .git/hooks does not exist" >&2 1>/dev/null
hooks: $(hooks)
deploy:
@echo "Deploying private/$(BRANCH) to $(RELEASE)..."
@git fetch oss
@git fetch private
@if test -n "`git rev-list private/$(BRANCH)..oss/$(BRANCH)`"; \
then \
echo "There are commits in oss/$(BRANCH) that are not in private/$(BRANCH). Please sync the remotes before deploying."; \
exit 1; \
fi
@if test "$(RELEASE)" != "beta" && test "$(RELEASE)" != "itunes"; \
then \
echo "RELEASE must be 'beta' or 'itunes'."; \
exit 1; \
fi
@if test "$(RELEASE)" = "itunes" && test "$(BRANCH)" != "master"; \
then \
echo "BRANCH must be 'master' for iTunes releases."; \
exit 1; \
fi
@git branch -f $(DIST_BRANCH) private/$(BRANCH)
@git push -f private $(DIST_BRANCH)
@git branch -d $(DIST_BRANCH)
@echo "Deploy has been kicked off to CircleCI!"
alpha:
@echo "Adding remotes..."
@git remote add oss https://github.com/kickstarter/ios-oss
@git remote add private https://github.com/kickstarter/ios-private
@echo "Deploying private/alpha-dist-$(COMMIT)..."
@git branch -f alpha-dist-$(COMMIT)
@git push -f private alpha-dist-$(COMMIT)
@git branch -d alpha-dist-$(COMMIT)
@echo "Deploy has been kicked off to CircleCI!"
sync:
@echo "Syncing oss and private remotes..."
@git checkout oss $(BRANCH)
@git pull oss $(BRANCH)
@git push private $(BRANCH)
@echo "private and oss remotes are now synced!"
cleanup:
@echo "Adding remotes..."
@git remote add oss https://github.com/kickstarter/ios-oss
@git remote add private https://github.com/kickstarter/ios-private
@echo "Deleting temporary branch: $(CIRCLE_BRANCH)"
@git push -d private $(CIRCLE_BRANCH)
lint:
swiftlint lint --reporter json --strict
strings:
cat Frameworks/native-secrets/ios/Secrets.swift bin/strings.swift \
| xcrun -sdk macosx swift -
secrets:
-@rm -rf Frameworks/native-secrets
-@git clone https://github.com/kickstarter/native-secrets Frameworks/native-secrets 2>/dev/null || echo '(Skipping secrets.)'
if [ ! -d Frameworks/native-secrets ]; \
then \
mkdir -p Frameworks/native-secrets/ios \
&& cp -n Configs/Secrets.swift.example Frameworks/native-secrets/ios/Secrets.swift \
|| true; \
fi
VERSION_FILE = Frameworks/OpenTok/version
CURRENT_OPENTOK_VERSION = $(shell cat $(VERSION_FILE))
ifeq ($(CURRENT_OPENTOK_VERSION),)
CURRENT_OPENTOK_VERSION = first
endif
opentok:
@if [ $(OPENTOK_VERSION) != $(CURRENT_OPENTOK_VERSION) ]; \
then \
echo "Downloading OpenTok v$(OPENTOK_VERSION)"; \
mkdir -p Frameworks/OpenTok; \
curl -s -N -L https://tokbox.com/downloads/opentok-ios-sdk-$(OPENTOK_VERSION) \
| tar -xz --strip 1 --directory Frameworks/OpenTok OpenTok-iOS-$(OPENTOK_VERSION)/OpenTok.framework \
|| true; \
fi
@if [ -e Frameworks/OpenTok/OpenTok.framework ]; \
then \
echo "$(OPENTOK_VERSION)" > $(VERSION_FILE); \
fi
fabric:
@if [ ! -d Frameworks/Fabric ]; then \
echo "Downloading Fabric v$(FABRIC_SDK_VERSION)"; \
mkdir -p Frameworks/Fabric; \
curl -N -L -o fabric.zip https://s3.amazonaws.com/kits-crashlytics-com/ios/com.twitter.crashlytics.ios/$(FABRIC_SDK_VERSION)/com.crashlytics.ios-manual.zip; \
unzip fabric.zip -d Frameworks/Fabric || true; \
rm fabric.zip; \
fi
@if [ -e Frameworks/Fabric/Fabric.framework ]; then \
echo "Fabric v$(FABRIC_SDK_VERSION) downloaded"; \
else \
echo "Failed to download Fabric SDK"; \
rm -rf Frameworks/Fabric; \
fi
stripe:
@if [ ! -d Frameworks/Stripe ]; then \
echo "Downloading Stripe SDK v$(STRIPE_SDK_VERSION)"; \
mkdir -p Frameworks/Stripe; \
curl -N -L -o stripe.zip https://github.com/stripe/stripe-ios/releases/download/v$(STRIPE_SDK_VERSION)/Stripe.framework.zip; \
unzip stripe.zip -d Frameworks/Stripe || true; \
rm stripe.zip; \
fi
@if [ -e Frameworks/Stripe/Stripe.framework ]; then \
echo "Stripe SDK v$(STRIPE_SDK_VERSION) downloaded"; \
else \
echo "Failed to download Stripe SDK"; \
rm -rf Frameworks/Stripe; \
fi
.PHONY: test-all test clean dependencies submodules deploy lint secrets strings opentok fabric