|
@@ -0,0 +1,100 @@
|
|
1
|
+# The script is based on tutorial written by Antonis Tsakiridis published at:
|
|
2
|
+# https://medium.com/@atsakiridis/continuous-deployment-for-ios-using-travis-ci-55dcea342d9
|
|
3
|
+#
|
|
4
|
+# APPLE_CERT_URL - the URL pointing to Apple certificate (set to
|
|
5
|
+# http://developer.apple.com/certificationauthority/AppleWWDRCA.cer by default)
|
|
6
|
+# DEPLOY_SSH_CERT_URL - the SSH private key used by the 'scp' command to deploy
|
|
7
|
+# the .ipa. It is expected to be encrypted with the $ENCRYPTION_PASSWORD.
|
|
8
|
+# ENCRYPTION_PASSWORD - the password used to decrypt certificate/key files used
|
|
9
|
+# in the script.
|
|
10
|
+# IOS_DEV_CERT_KEY_URL - URL pointing to provisioning profile certificate key
|
|
11
|
+# file (development-key.p12.enc from the tutorial) encrypted with the
|
|
12
|
+# $ENCRYPTION_PASSWORD.
|
|
13
|
+# IOS_DEV_CERT_URL - URL pointing to provisioning profile certificate file
|
|
14
|
+# (development-cert.cer.enc from the tutorial) encrypted with the
|
|
15
|
+# $ENCRYPTION_PASSWORD.
|
|
16
|
+# IOS_DEV_PROV_PROFILE_URL - URL pointing to provisioning profile file
|
|
17
|
+# (profile-development-olympus.mobileprovision.enc from the tutorial) encrypted
|
|
18
|
+# IOS_DEV_WATCH_PROV_PROFILE_URL - URL pointing to watch app provisioning profile file(encrypted).
|
|
19
|
+# with the $ENCRYPTION_PASSWORD.
|
|
20
|
+# IOS_SIGNING_CERT_PASSWORD - the password to the provisioning profile
|
|
21
|
+# certificate key (used to open development-key.p12 from the tutorial).
|
|
22
|
+
|
|
23
|
+function echoAndExit1() {
|
|
24
|
+ echo $1
|
|
25
|
+ exit 1
|
|
26
|
+}
|
|
27
|
+
|
|
28
|
+CERT_DIR=$1
|
|
29
|
+
|
|
30
|
+if [ -z $CERT_DIR ]; then
|
|
31
|
+ echoAndExit1 "First argument must be certificates directory"
|
|
32
|
+fi
|
|
33
|
+
|
|
34
|
+if [ -z $APPLE_CERT_URL ]; then
|
|
35
|
+ APPLE_CERT_URL="http://developer.apple.com/certificationauthority/AppleWWDRCA.cer"
|
|
36
|
+fi
|
|
37
|
+
|
|
38
|
+if [ -z $DEPLOY_SSH_CERT_URL ]; then
|
|
39
|
+ echoAndExit1 "DEPLOY_SSH_CERT_URL env var is not defined"
|
|
40
|
+fi
|
|
41
|
+
|
|
42
|
+if [ -z $ENCRYPTION_PASSWORD ]; then
|
|
43
|
+ echoAndExit1 "ENCRYPTION_PASSWORD env var is not defined"
|
|
44
|
+fi
|
|
45
|
+
|
|
46
|
+if [ -z $IOS_DEV_CERT_KEY_URL ]; then
|
|
47
|
+ echoAndExit1 "IOS_DEV_CERT_KEY_URL env var is not defined"
|
|
48
|
+fi
|
|
49
|
+
|
|
50
|
+if [ -z $IOS_DEV_CERT_URL ]; then
|
|
51
|
+ echoAndExit1 "IOS_DEV_CERT_URL env var is not defined"
|
|
52
|
+fi
|
|
53
|
+
|
|
54
|
+if [ -z $IOS_DEV_PROV_PROFILE_URL ]; then
|
|
55
|
+ echoAndExit1 "IOS_DEV_PROV_PROFILE_URL env var is not defined"
|
|
56
|
+fi
|
|
57
|
+
|
|
58
|
+if [ -z $IOS_DEV_WATCH_PROV_PROFILE_URL ]; then
|
|
59
|
+ echoAndExit1 "IOS_DEV_WATCH_PROV_PROFILE_URL env var is not defined"
|
|
60
|
+fi
|
|
61
|
+
|
|
62
|
+if [ -z $IOS_SIGNING_CERT_PASSWORD ]; then
|
|
63
|
+ echoAndExit1 "IOS_SIGNING_CERT_PASSWORD env var is not defined"
|
|
64
|
+fi
|
|
65
|
+
|
|
66
|
+# certificates
|
|
67
|
+
|
|
68
|
+curl -L -o ${CERT_DIR}/AppleWWDRCA.cer 'http://developer.apple.com/certificationauthority/AppleWWDRCA.cer'
|
|
69
|
+curl -L -o ${CERT_DIR}/dev-cert.cer.enc ${IOS_DEV_CERT_URL}
|
|
70
|
+curl -L -o ${CERT_DIR}/dev-key.p12.enc ${IOS_DEV_CERT_KEY_URL}
|
|
71
|
+curl -L -o ${CERT_DIR}/dev-profile.mobileprovision.enc ${IOS_DEV_PROV_PROFILE_URL}
|
|
72
|
+curl -L -o ${CERT_DIR}/dev-watch-profile.mobileprovision.enc ${IOS_DEV_WATCH_PROV_PROFILE_URL}
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+openssl aes-256-cbc -k "$ENCRYPTION_PASSWORD" -in ${CERT_DIR}/dev-cert.cer.enc -d -a -out ${CERT_DIR}/dev-cert.cer
|
|
76
|
+openssl aes-256-cbc -k "$ENCRYPTION_PASSWORD" -in ${CERT_DIR}/dev-key.p12.enc -d -a -out ${CERT_DIR}/dev-key.p12
|
|
77
|
+openssl aes-256-cbc -k "$ENCRYPTION_PASSWORD" -in ${CERT_DIR}/dev-profile.mobileprovision.enc -d -a -out ${CERT_DIR}/dev-profile.mobileprovision
|
|
78
|
+openssl aes-256-cbc -k "$ENCRYPTION_PASSWORD" -in ${CERT_DIR}/dev-watch-profile.mobileprovision.enc -d -a -out ${CERT_DIR}/dev-watch-profile.mobileprovision
|
|
79
|
+
|
|
80
|
+security create-keychain -p $ENCRYPTION_PASSWORD ios-build.keychain
|
|
81
|
+security default-keychain -s ios-build.keychain
|
|
82
|
+security unlock-keychain -p $ENCRYPTION_PASSWORD ios-build.keychain
|
|
83
|
+security set-keychain-settings -t 3600 -l ~/Library/Keychains/ios-build.keychain
|
|
84
|
+
|
|
85
|
+echo "importing Apple cert"
|
|
86
|
+security import ${CERT_DIR}/AppleWWDRCA.cer -k ios-build.keychain -A
|
|
87
|
+echo "importing dev-cert.cer"
|
|
88
|
+security import ${CERT_DIR}/dev-cert.cer -k ios-build.keychain -A
|
|
89
|
+echo "importing dev-key.p12"
|
|
90
|
+security import ${CERT_DIR}/dev-key.p12 -k ios-build.keychain -P $IOS_SIGNING_CERT_PASSWORD -A
|
|
91
|
+
|
|
92
|
+echo "will set-key-partition-list"
|
|
93
|
+# Fix for OS X Sierra that hungs in the codesign step
|
|
94
|
+security set-key-partition-list -S apple-tool:,apple: -s -k $ENCRYPTION_PASSWORD ios-build.keychain > /dev/null
|
|
95
|
+echo "done set-key-partition-list"
|
|
96
|
+
|
|
97
|
+mkdir -p ~/Library/MobileDevice/Provisioning\ Profiles
|
|
98
|
+
|
|
99
|
+cp "${CERT_DIR}/dev-profile.mobileprovision" ~/Library/MobileDevice/Provisioning\ Profiles/
|
|
100
|
+cp "${CERT_DIR}/dev-watch-profile.mobileprovision" ~/Library/MobileDevice/Provisioning\ Profiles/
|