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 merge 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