Quellcode durchsuchen

Generic iOS .ipa build script (#4775)

master
Paweł Domas vor 5 Jahren
Ursprung
Commit
4b9e156c5d
Es ist kein Account mit der E-Mail-Adresse des Committers verbunden
4 geänderte Dateien mit 212 neuen und 45 gelöschten Zeilen
  1. 0
    0
      ios/ci/build-ipa.plist.template
  2. 103
    0
      ios/ci/build-ipa.sh
  3. 100
    0
      ios/ci/setup-certificates.sh
  4. 9
    45
      ios/travis-ci/build-ipa.sh

ios/travis-ci/build-ipa.plist.template → ios/ci/build-ipa.plist.template Datei anzeigen


+ 103
- 0
ios/ci/build-ipa.sh Datei anzeigen

@@ -0,0 +1,103 @@
1
+#!/bin/bash
2
+set -e
3
+
4
+# Mandatory arguments with no default values provided:
5
+# PR_REPO_SLUG - the Github name of the repo to be merged into the origin/master
6
+# PR_BRANCH - the branch to be merged, if set to "master" no merge will happen
7
+# IPA_DEPLOY_LOCATION - the location understandable by the "scp" command
8
+# executed at the end of the script to deploy the output .ipa file
9
+# LIB_JITSI_MEET_PKG (optional) - the npm package for lib-jitsi-meet which will
10
+# be put in place of the current version in the package.json file.
11
+#
12
+# Other than that the script requires the following env variables to be set:
13
+#
14
+# DEPLOY_SSH_CERT_URL - the SSH private key used by the 'scp' command to deploy
15
+# the .ipa. It is expected to be encrypted with the $ENCRYPTION_PASSWORD.
16
+# ENCRYPTION_PASSWORD - the password used to decrypt certificate/key files used
17
+# in the script.
18
+# IOS_TEAM_ID - the team ID inserted into build-ipa-.plist.template file in
19
+# place of "YOUR_TEAM_ID".
20
+
21
+function echoAndExit1() {
22
+    echo $1
23
+    exit 1
24
+}
25
+
26
+if [ -z $PR_REPO_SLUG ]; then
27
+    echoAndExit1 "No PR_REPO_SLUG defined"
28
+fi
29
+if [ -z $PR_BRANCH ]; then
30
+    echoAndExit1 "No PR_BRANCH defined"
31
+fi
32
+if [ -z $IPA_DEPLOY_LOCATION ]; then
33
+    echoAndExit1 "No IPA_DEPLOY_LOCATION defined"
34
+fi
35
+
36
+echo "PR_REPO_SLUG=${PR_REPO_SLUG} PR_BRANCH=${PR_BRANCH}"
37
+
38
+# do the marge and git log
39
+
40
+if [ $PR_BRANCH != "master" ]; then
41
+    echo "Will merge ${PR_REPO_SLUG}/${PR_BRANCH} into master"
42
+    git config remote.origin.fetch "+refs/heads/*:refs/remotes/origin/*"
43
+    git fetch origin master
44
+    git checkout master
45
+    git pull https://github.com/${PR_REPO_SLUG}.git $PR_BRANCH --no-edit
46
+fi
47
+
48
+# Link this lib-jitsi-meet checkout in jitsi-meet through the package.json
49
+if [ ! -z ${LIB_JITSI_MEET_PKG} ];
50
+then
51
+    echo "Adjusting lib-jitsi-meet package in package.json to ${LIB_JITSI_MEET_PKG}"
52
+    # escape for the sed
53
+    LIB_JITSI_MEET_PKG=$(echo $LIB_JITSI_MEET_PKG | sed -e 's/\\/\\\\/g; s/\//\\\//g; s/&/\\\&/g')
54
+    sed -i.bak -e "s/\"lib-jitsi-meet.*/\"lib-jitsi-meet\"\: \"${LIB_JITSI_MEET_PKG}\",/g" package.json
55
+    echo "Package.json lib-jitsi-meet line:"
56
+    grep lib-jitsi-meet package.json
57
+else
58
+    echo "LIB_JITSI_MEET_PKG var not set - will not modify the package.json"
59
+fi
60
+
61
+git log -20 --graph --pretty=format':%C(yellow)%h%Cblue%d%Creset %s %C(white) %an, %ar%Creset'
62
+
63
+# certificates
64
+
65
+CERT_DIR="ios/ci/certs"
66
+
67
+mkdir -p $CERT_DIR
68
+
69
+curl -L -o ${CERT_DIR}/id_rsa.enc ${DEPLOY_SSH_CERT_URL}
70
+openssl aes-256-cbc -k "$ENCRYPTION_PASSWORD" -in ${CERT_DIR}/id_rsa.enc -d -a -out ${CERT_DIR}/id_rsa
71
+chmod 0600 ${CERT_DIR}/id_rsa
72
+ssh-add ${CERT_DIR}/id_rsa
73
+
74
+npm install
75
+
76
+# Ever since the Apple Watch app has been added the bitcode for WebRTC needs to be downloaded in order to build successfully
77
+./node_modules/react-native-webrtc/tools/downloadBitcode.sh
78
+
79
+cd ios
80
+pod install --repo-update --no-ansi
81
+cd ..
82
+
83
+mkdir -p /tmp/jitsi-meet/
84
+
85
+xcodebuild archive -quiet -workspace ios/jitsi-meet.xcworkspace -scheme jitsi-meet -configuration Release -archivePath /tmp/jitsi-meet/jitsi-meet.xcarchive
86
+
87
+sed -e "s/YOUR_TEAM_ID/${IOS_TEAM_ID}/g" ios/ci/build-ipa.plist.template > ios/ci/build-ipa.plist
88
+
89
+IPA_EXPORT_DIR=/tmp/jitsi-meet/jitsi-meet-ipa
90
+
91
+xcodebuild -quiet -exportArchive -archivePath /tmp/jitsi-meet/jitsi-meet.xcarchive -exportPath $IPA_EXPORT_DIR  -exportOptionsPlist ios/ci/build-ipa.plist
92
+
93
+echo "Will try deploy the .ipa to: ${IPA_DEPLOY_LOCATION}"
94
+
95
+if [ ! -z ${SCP_PROXY_HOST} ];
96
+then
97
+    scp -o ProxyCommand="ssh -t -A -l %r ${SCP_PROXY_HOST} -o \"StrictHostKeyChecking no\" -o \"BatchMode yes\" -W %h:%p"  -o StrictHostKeyChecking=no -o LogLevel=DEBUG "${IPA_EXPORT_DIR}/jitsi-meet.ipa" "${IPA_DEPLOY_LOCATION}"
98
+else
99
+    scp -o StrictHostKeyChecking=no -o LogLevel=DEBUG "${IPA_EXPORT_DIR}/jitsi-meet.ipa" "${IPA_DEPLOY_LOCATION}"
100
+fi
101
+
102
+rm -r /tmp/jitsi-meet/
103
+rm -r $CERT_DIR

+ 100
- 0
ios/ci/setup-certificates.sh Datei anzeigen

@@ -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/

+ 9
- 45
ios/travis-ci/build-ipa.sh Datei anzeigen

@@ -37,6 +37,7 @@ set -e
37 37
 # IOS_TEAM_ID - the team ID inserted into build-ipa-.plist.template file in
38 38
 # place of "YOUR_TEAM_ID".
39 39
 
40
+
40 41
 # Travis will not print the last echo if there's no sleep 1
41 42
 function echoSleepAndExit1() {
42 43
     echo $1
@@ -57,10 +58,6 @@ if [ -z $IPA_DEPLOY_LOCATION ]; then
57 58
     echoSleepAndExit1 "No IPA_DEPLOY_LOCATION defined"
58 59
 fi
59 60
 
60
-if [ -z $APPLE_CERT_URL ]; then
61
-    APPLE_CERT_URL="http://developer.apple.com/certificationauthority/AppleWWDRCA.cer"
62
-fi
63
-
64 61
 echo "PR_REPO_SLUG=${PR_REPO_SLUG} PR_BRANCH=${PR_BRANCH}"
65 62
 
66 63
 # do the marge and git log
@@ -88,47 +85,17 @@ fi
88 85
 
89 86
 git log -20 --graph --pretty=format':%C(yellow)%h%Cblue%d%Creset %s %C(white) %an, %ar%Creset'
90 87
 
91
-# certificates
92
-
88
+#certificates
93 89
 CERT_DIR="ios/travis-ci/certs"
94 90
 
95
-mkdir $CERT_DIR
91
+mkdir -p $CERT_DIR
96 92
 
97
-curl -L -o ${CERT_DIR}/AppleWWDRCA.cer 'http://developer.apple.com/certificationauthority/AppleWWDRCA.cer'
98
-curl -L -o ${CERT_DIR}/dev-cert.cer.enc ${IOS_DEV_CERT_URL}
99
-curl -L -o ${CERT_DIR}/dev-key.p12.enc ${IOS_DEV_CERT_KEY_URL}
100
-curl -L -o ${CERT_DIR}/dev-profile.mobileprovision.enc ${IOS_DEV_PROV_PROFILE_URL}
101
-curl -L -o ${CERT_DIR}/dev-watch-profile.mobileprovision.enc ${IOS_DEV_WATCH_PROV_PROFILE_URL}
102
-curl -L -o ${CERT_DIR}/id_rsa.enc ${DEPLOY_SSH_CERT_URL}
93
+./ios/ci/setup-certificates.sh $CERT_DIR
103 94
 
104
-openssl aes-256-cbc -k "$ENCRYPTION_PASSWORD" -in ${CERT_DIR}/dev-cert.cer.enc -d -a -out ${CERT_DIR}/dev-cert.cer
105
-openssl aes-256-cbc -k "$ENCRYPTION_PASSWORD" -in ${CERT_DIR}/dev-key.p12.enc -d -a -out ${CERT_DIR}/dev-key.p12
106
-openssl aes-256-cbc -k "$ENCRYPTION_PASSWORD" -in ${CERT_DIR}/dev-profile.mobileprovision.enc -d -a -out ${CERT_DIR}/dev-profile.mobileprovision
107
-openssl aes-256-cbc -k "$ENCRYPTION_PASSWORD" -in ${CERT_DIR}/dev-watch-profile.mobileprovision.enc -d -a -out ${CERT_DIR}/dev-watch-profile.mobileprovision
95
+curl -L -o ${CERT_DIR}/id_rsa.enc ${DEPLOY_SSH_CERT_URL}
108 96
 openssl aes-256-cbc -k "$ENCRYPTION_PASSWORD" -in ${CERT_DIR}/id_rsa.enc -d -a -out ${CERT_DIR}/id_rsa
109 97
 chmod 0600 ${CERT_DIR}/id_rsa
110
-
111
-security create-keychain -p $ENCRYPTION_PASSWORD ios-build.keychain
112
-security default-keychain -s ios-build.keychain
113
-security unlock-keychain -p $ENCRYPTION_PASSWORD ios-build.keychain
114
-security set-keychain-settings -t 3600 -l ~/Library/Keychains/ios-build.keychain
115
-
116
-echo "importing Apple cert"
117
-security import ${CERT_DIR}/AppleWWDRCA.cer -k ios-build.keychain -A
118
-echo "importing dev-cert.cer"
119
-security import ${CERT_DIR}/dev-cert.cer -k ios-build.keychain -A
120
-echo "importing dev-key.p12"
121
-security import ${CERT_DIR}/dev-key.p12 -k ios-build.keychain -P $IOS_SIGNING_CERT_PASSWORD -A
122
-
123
-echo "will set-key-partition-list"
124
-# Fix for OS X Sierra that hungs in the codesign step
125
-security set-key-partition-list -S apple-tool:,apple: -s -k $ENCRYPTION_PASSWORD ios-build.keychain > /dev/null
126
-echo "done set-key-partition-list"
127
-
128
-mkdir -p ~/Library/MobileDevice/Provisioning\ Profiles
129
-
130
-cp "${CERT_DIR}/dev-profile.mobileprovision"  ~/Library/MobileDevice/Provisioning\ Profiles/
131
-cp "${CERT_DIR}/dev-watch-profile.mobileprovision"  ~/Library/MobileDevice/Provisioning\ Profiles/
98
+ssh-add ${CERT_DIR}/id_rsa
132 99
 
133 100
 npm install
134 101
 
@@ -136,24 +103,21 @@ npm install
136 103
 ./node_modules/react-native-webrtc/tools/downloadBitcode.sh
137 104
 
138 105
 cd ios
139
-pod update
140
-pod install
106
+pod install --repo-update --no-ansi
141 107
 cd ..
142 108
 
143 109
 mkdir -p /tmp/jitsi-meet/
144 110
 
145 111
 xcodebuild archive -quiet -workspace ios/jitsi-meet.xcworkspace -scheme jitsi-meet -configuration Release -archivePath /tmp/jitsi-meet/jitsi-meet.xcarchive
146 112
 
147
-sed -e "s/YOUR_TEAM_ID/${IOS_TEAM_ID}/g" ios/travis-ci/build-ipa.plist.template > ios/travis-ci/build-ipa.plist
113
+sed -e "s/YOUR_TEAM_ID/${IOS_TEAM_ID}/g" ios/ci/build-ipa.plist.template > ios/ci/build-ipa.plist
148 114
 
149 115
 IPA_EXPORT_DIR=/tmp/jitsi-meet/jitsi-meet-ipa
150 116
 
151
-xcodebuild -quiet -exportArchive -archivePath /tmp/jitsi-meet/jitsi-meet.xcarchive -exportPath $IPA_EXPORT_DIR  -exportOptionsPlist ios/travis-ci/build-ipa.plist
117
+xcodebuild -quiet -exportArchive -archivePath /tmp/jitsi-meet/jitsi-meet.xcarchive -exportPath $IPA_EXPORT_DIR  -exportOptionsPlist ios/ci/build-ipa.plist
152 118
 
153 119
 echo "Will try deploy the .ipa to: ${IPA_DEPLOY_LOCATION}"
154 120
 
155
-ssh-add ${CERT_DIR}/id_rsa
156
-
157 121
 if [ ! -z ${SCP_PROXY_HOST} ];
158 122
 then
159 123
     scp -o ProxyCommand="ssh -t -A -l %r ${SCP_PROXY_HOST} -o \"StrictHostKeyChecking no\" -o \"BatchMode yes\" -W %h:%p"  -o StrictHostKeyChecking=no -o LogLevel=DEBUG "${IPA_EXPORT_DIR}/jitsi-meet.ipa" "${IPA_DEPLOY_LOCATION}"

Laden…
Abbrechen
Speichern