Skip to content

Commit

Permalink
Reusable download framework script (#564)
Browse files Browse the repository at this point in the history
* Download Fabric and Stripe SDKs using a reusable script.

* Improve indentation

* Move URL to env var

* Use new sdk cache key

* Cache stripe sdk

* Always store stripe version in text file for checksum

* Fix copy-paste typo

* Consistency fix
  • Loading branch information
justinswart authored Feb 4, 2019
1 parent 01960ec commit 4f54b49
Show file tree
Hide file tree
Showing 3 changed files with 131 additions and 47 deletions.
120 changes: 100 additions & 20 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@ xcode_version: &xcode_version 10.0
iphone_name: &iphone_name iPhone 8
opentok_version: &opentok_version 2.10.2
fabric_sdk_version: &fabric_sdk_version 3.10.5
stripe_sdk_version: &stripe_sdk_version 13.2.0
store_fabric_sdk_version: &store_fabric_sdk_version echo "$FABRIC_SDK_VERSION" > fabric_version.txt
store_opentok_version: &store_opentok_version echo "$OPENTOK_VERSION" > opentok_version.txt
store_stripe_version: &store_stripe_version echo "$STRIPE_SDK_VERSION" > stripe_version.txt

base_job: &base_job
macos:
Expand All @@ -18,6 +20,7 @@ base_job: &base_job
LC_ALL: en_US.UTF-8
LANG: en_US.UTF-8
FABRIC_SDK_VERSION: *fabric_sdk_version
STRIPE_SDK_VERSION: *stripe_sdk_version
OPENTOK_VERSION: *opentok_version
IPHONE_NAME: *iphone_name
XCODE_VERSION: *xcode_version
Expand All @@ -42,13 +45,21 @@ jobs:
name: Store OpenTok Version
command: *store_opentok_version

- run:
name: Store Stripe Version
command: *store_stripe_version

- restore_cache:
keys:
- opentok-sdk-cache-{{ checksum "opentok_version.txt" }}

- restore_cache:
keys:
- opentok-cache-{{ checksum "opentok_version.txt" }}
- fabric-sdk-cache-{{ checksum "fabric_version.txt" }}

- restore_cache:
keys:
- fabric-cache-{{ checksum "fabric_version.txt" }}
- stripe-sdk-cache-{{ checksum "stripe_version.txt" }}

- run:
name: Make bootstrap
Expand All @@ -60,15 +71,20 @@ jobs:
- ".git"

- save_cache:
key: opentok-cache-{{ checksum "opentok_version.txt" }}
key: opentok-sdk-cache-{{ checksum "opentok_version.txt" }}
paths:
- "Frameworks/OpenTok"

- save_cache:
key: fabric-cache-{{ checksum "fabric_version.txt" }}
key: fabric-sdk-cache-{{ checksum "fabric_version.txt" }}
paths:
- "Frameworks/Fabric"

- save_cache:
key: stripe-sdk-cache-{{ checksum "stripe_version.txt" }}
paths:
- "Frameworks/Stripe"

- run:
name: SwiftLint
command: make lint
Expand Down Expand Up @@ -96,13 +112,21 @@ jobs:
name: Store OpenTok Version
command: *store_opentok_version

- run:
name: Store Stripe Version
command: *store_stripe_version

- restore_cache:
keys:
- opentok-sdk-cache-{{ checksum "opentok_version.txt" }}

- restore_cache:
keys:
- opentok-cache-{{ checksum "opentok_version.txt" }}
- fabric-sdk-cache-{{ checksum "fabric_version.txt" }}

- restore_cache:
keys:
- fabric-cache-{{ checksum "fabric_version.txt" }}
- stripe-sdk-cache-{{ checksum "stripe_version.txt" }}

- run:
name: Make bootstrap
Expand Down Expand Up @@ -137,13 +161,21 @@ jobs:
name: Store OpenTok Version
command: *store_opentok_version

- run:
name: Store Stripe Version
command: *store_stripe_version

- restore_cache:
keys:
- opentok-sdk-cache-{{ checksum "opentok_version.txt" }}

- restore_cache:
keys:
- opentok-cache-{{ checksum "opentok_version.txt" }}
- fabric-sdk-cache-{{ checksum "fabric_version.txt" }}

- restore_cache:
keys:
- fabric-cache-{{ checksum "fabric_version.txt" }}
- stripe-sdk-cache-{{ checksum "stripe_version.txt" }}

- run:
name: Make bootstrap
Expand Down Expand Up @@ -176,13 +208,21 @@ jobs:
name: Store OpenTok Version
command: *store_opentok_version

- run:
name: Store Stripe Version
command: *store_stripe_version

- restore_cache:
keys:
- opentok-sdk-cache-{{ checksum "opentok_version.txt" }}

- restore_cache:
keys:
- opentok-cache-{{ checksum "opentok_version.txt" }}
- fabric-sdk-cache-{{ checksum "fabric_version.txt" }}

- restore_cache:
keys:
- fabric-cache-{{ checksum "fabric_version.txt" }}
- stripe-sdk-cache-{{ checksum "stripe_version.txt" }}

- run:
name: Make bootstrap
Expand Down Expand Up @@ -215,13 +255,21 @@ jobs:
name: Store OpenTok Version
command: *store_opentok_version

- run:
name: Store Stripe Version
command: *store_stripe_version

- restore_cache:
keys:
- opentok-sdk-cache-{{ checksum "opentok_version.txt" }}

- restore_cache:
keys:
- opentok-cache-{{ checksum "opentok_version.txt" }}
- fabric-sdk-cache-{{ checksum "fabric_version.txt" }}

- restore_cache:
keys:
- fabric-cache-{{ checksum "fabric_version.txt" }}
- stripe-sdk-cache-{{ checksum "stripe_version.txt" }}

- run:
name: Make bootstrap
Expand Down Expand Up @@ -271,13 +319,21 @@ jobs:
name: Store OpenTok Version
command: *store_opentok_version

- run:
name: Store Stripe Version
command: *store_stripe_version

- restore_cache:
keys:
- opentok-cache-{{ checksum "opentok_version.txt" }}
- opentok-sdk-cache-{{ checksum "opentok_version.txt" }}

- restore_cache:
keys:
- fabric-cache-{{ checksum "fabric_version.txt" }}
- fabric-sdk-cache-{{ checksum "fabric_version.txt" }}

- restore_cache:
keys:
- stripe-sdk-cache-{{ checksum "stripe_version.txt" }}

- run:
name: Make bootstrap
Expand Down Expand Up @@ -336,13 +392,21 @@ jobs:
name: Store OpenTok Version
command: *store_opentok_version

- run:
name: Store Stripe Version
command: *store_stripe_version

- restore_cache:
keys:
- opentok-sdk-cache-{{ checksum "opentok_version.txt" }}

- restore_cache:
keys:
- opentok-cache-{{ checksum "opentok_version.txt" }}
- fabric-sdk-cache-{{ checksum "fabric_version.txt" }}

- restore_cache:
keys:
- fabric-cache-{{ checksum "fabric_version.txt" }}
- stripe-sdk-cache-{{ checksum "stripe_version.txt" }}

- run:
name: Make bootstrap
Expand Down Expand Up @@ -396,13 +460,21 @@ jobs:
name: Store OpenTok Version
command: *store_opentok_version

- run:
name: Store Stripe Version
command: *store_stripe_version

- restore_cache:
keys:
- opentok-sdk-cache-{{ checksum "opentok_version.txt" }}

- restore_cache:
keys:
- opentok-cache-{{ checksum "opentok_version.txt" }}
- fabric-sdk-cache-{{ checksum "fabric_version.txt" }}

- restore_cache:
keys:
- fabric-cache-{{ checksum "fabric_version.txt" }}
- stripe-sdk-cache-{{ checksum "stripe_version.txt" }}

- run:
name: Make bootstrap
Expand Down Expand Up @@ -445,13 +517,21 @@ jobs:
name: Store OpenTok Version
command: *store_opentok_version

- run:
name: Store Stripe Version
command: *store_stripe_version

- restore_cache:
keys:
- opentok-sdk-cache-{{ checksum "opentok_version.txt" }}

- restore_cache:
keys:
- opentok-cache-{{ checksum "opentok_version.txt" }}
- fabric-sdk-cache-{{ checksum "fabric_version.txt" }}

- restore_cache:
keys:
- fabric-cache-{{ checksum "fabric_version.txt" }}
- stripe-sdk-cache-{{ checksum "stripe_version.txt" }}

- run:
name: Make bootstrap
Expand Down
31 changes: 4 additions & 27 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ BRANCH ?= master
DIST_BRANCH = $(RELEASE)-dist
OPENTOK_VERSION ?= 2.10.2
FABRIC_SDK_VERSION ?= 3.10.5
FABRIC_SDK_URL ?= https://s3.amazonaws.com/kits-crashlytics-com/ios/com.twitter.crashlytics.ios/INSERT_SDK_VERSION/com.crashlytics.ios-manual.zip
STRIPE_SDK_VERSION ?= 13.2.0
STRIPE_SDK_URL ?= https://github.com/stripe/stripe-ios/releases/download/vINSERT_SDK_VERSION/Stripe.framework.zip
COMMIT ?= $(CIRCLE_SHA1)

ifeq ($(PLATFORM),iOS)
Expand Down Expand Up @@ -161,34 +163,9 @@ opentok:
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
bin/download_framework.sh Fabric $(FABRIC_SDK_VERSION) $(FABRIC_SDK_URL); \

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

bin/download_framework.sh Stripe $(STRIPE_SDK_VERSION) $(STRIPE_SDK_URL); \

.PHONY: test-all test clean dependencies submodules deploy lint secrets strings opentok fabric
27 changes: 27 additions & 0 deletions bin/download_framework.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#!/bin/sh

SDK_NAME=$1
SDK_VERSION=$2
URL=$3
FRAMEWORK_DIR=Frameworks/$SDK_NAME
VERSION_FILE=$FRAMEWORK_DIR/version
CURRENT_SDK_VERSION=first

if [ -e $VERSION_FILE ]; then \
while read value; do
CURRENT_SDK_VERSION=$value
done < $VERSION_FILE
fi

URL=${URL//INSERT_SDK_VERSION/"$SDK_VERSION"}

if [ "$SDK_VERSION" != "$CURRENT_SDK_VERSION" ]; then \
echo "Downloading $SDK_NAME v$SDK_VERSION"; \
mkdir -p Frameworks/$SDK_NAME; \
curl -N -L -o framework.zip $URL; \
unzip -o framework.zip -d Frameworks/$SDK_NAME; \
rm framework.zip; \
fi
if [ -e Frameworks/$SDK_NAME/$SDK_NAME.framework ]; then \
echo "$SDK_VERSION" > $VERSION_FILE; \
fi

0 comments on commit 4f54b49

Please sign in to comment.