You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

build-ipa.sh 5.1KB

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