瀏覽代碼

feat(iOS): build .ipa for PRs in Travis CI

master
paweldomas 7 年之前
父節點
當前提交
8ca836c922
共有 3 個檔案被更改,包括 170 行新增0 行删除
  1. 4
    0
      .travis.yml
  2. 18
    0
      ios/travis-ci/build-ipa.plist.template
  3. 148
    0
      ios/travis-ci/build-ipa.sh

+ 4
- 0
.travis.yml 查看文件

@@ -0,0 +1,4 @@
1
+osx_image:
2
+language: objective-c
3
+script:
4
+- "./ios/travis-ci/build-ipa.sh"

+ 18
- 0
ios/travis-ci/build-ipa.plist.template 查看文件

@@ -0,0 +1,18 @@
1
+<?xml version="1.0" encoding="UTF-8"?>
2
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3
+<plist version="1.0">
4
+<dict>
5
+  <key>compileBitcode</key>
6
+  <false/>
7
+  <key>method</key>
8
+  <string>development</string>
9
+  <key>signingStyle</key>
10
+  <string>automatic</string>
11
+  <key>stripSwiftSymbols</key>
12
+  <true/>
13
+  <key>teamID</key>
14
+  <string>YOUR_TEAM_ID</string>
15
+  <key>thinning</key>
16
+  <string>&lt;none&gt;</string>
17
+</dict>
18
+</plist>

+ 148
- 0
ios/travis-ci/build-ipa.sh 查看文件

@@ -0,0 +1,148 @@
1
+#!/bin/bash
2
+set -e
3
+
4
+# The script is based on tutorial written by Antonis Tsakiridis published at:
5
+# https://medium.com/@atsakiridis/continuous-deployment-for-ios-using-travis-ci-55dcea342d9
6
+#
7
+# It is intended to be executed through the Travis CI REST API call, as it
8
+# requires few arguments which are mandatory with no default values provided:
9
+# PR_REPO_SLUG - the Github name of the repo to be merged into the origin/master
10
+# PR_BRANCH - the branch to be merged, if set to "master" no merge will happen
11
+# IPA_DEPLOY_LOCATION - the location understandable by the "scp" command
12
+# executed at the end of the script to deploy the output .ipa file
13
+# LIB_JITSI_MEET_PKG (optional) - the npm package for lib-jitsi-meet which will
14
+# be put in place of the current version in the package.json file.
15
+#
16
+# Other than that the script requires the following env variables to be set
17
+# (reading the tutorial mentioned above will help in understanding the
18
+# variables):
19
+#
20
+# APPLE_CERT_URL - the URL pointing to Apple certificate (set to
21
+# http://developer.apple.com/certificationauthority/AppleWWDRCA.cer by default)
22
+# DEPLOY_SSH_CERT_URL - the SSH private key used by the 'scp' command to deploy
23
+# the .ipa. It is expected to be encrypted with the $ENCRYPTION_PASSWORD.
24
+# ENCRYPTION_PASSWORD - the password used to decrypt certificate/key files used
25
+# in the script.
26
+# IOS_DEV_CERT_KEY_URL - URL pointing to provisioning profile certificate key
27
+# file (development-key.p12.enc from the tutorial) encrypted with the
28
+# $ENCRYPTION_PASSWORD.
29
+# IOS_DEV_CERT_URL - URL pointing to provisioning profile certificate file
30
+# (development-cert.cer.enc from the tutorial) encrypted with the
31
+# $ENCRYPTION_PASSWORD.
32
+# IOS_DEV_PROV_PROFILE_URL - URL pointing to provisioning profile file
33
+# (profile-development-olympus.mobileprovision.enc from the tutorial) encrypted
34
+# with the $ENCRYPTION_PASSWORD.
35
+# IOS_SIGNING_CERT_PASSWORD - the password to the provisioning profile
36
+# certificate key (used to open development-key.p12 from the tutorial).
37
+# IOS_TEAM_ID - the team ID inserted into build-ipa-.plist.template file in
38
+# place of "YOUR_TEAM_ID".
39
+
40
+# Travis will not print the last echo if there's no sleep 1
41
+function echoSleepAndExit1() {
42
+    echo $1
43
+    sleep 1
44
+    exit 1
45
+}
46
+
47
+echo "TRAVIS_BRANCH=${TRAVIS_BRANCH}"
48
+echo "TRAVIS_REPO_SLUG=${TRAVIS_REPO_SLUG}"
49
+
50
+if [ -z $PR_REPO_SLUG ]; then
51
+    echoSleepAndExit1 "No PR_REPO_SLUG defined"
52
+fi
53
+if [ -z $PR_BRANCH ]; then
54
+    echoSleepAndExit1 "No PR_BRANCH defined"
55
+fi
56
+if [ -z $IPA_DEPLOY_LOCATION ]; then
57
+    echoSleepAndExit1 "No IPA_DEPLOY_LOCATION defined"
58
+fi
59
+
60
+if [ -z $APPLE_CERT_URL ]; then
61
+    APPLE_CERT_URL="http://developer.apple.com/certificationauthority/AppleWWDRCA.cer"
62
+fi
63
+
64
+echo "PR_REPO_SLUG=${PR_REPO_SLUG} PR_BRANCH=${PR_BRANCH}"
65
+
66
+# do the marge and git log
67
+
68
+if [ $PR_BRANCH != "master" ]; then
69
+    echo "Will merge ${PR_REPO_SLUG}/${PR_BRANCH} into master"
70
+    git config remote.origin.fetch "+refs/heads/*:refs/remotes/origin/*"
71
+    git fetch origin master
72
+    git checkout master
73
+    git pull https://github.com/${PR_REPO_SLUG}.git $PR_BRANCH --no-edit
74
+fi
75
+
76
+# Link this lib-jitsi-meet checkout in jitsi-meet through the package.json
77
+if [ ! -z ${LIB_JITSI_MEET_PKG} ];
78
+then
79
+    echo "Adjusting lib-jitsi-meet package in package.json to ${LIB_JITSI_MEET_PKG}"
80
+    # escape / for the sed
81
+    LIB_JITSI_MEET_PKG=${LIB_JITSI_MEET_PKG/\//\\/}
82
+    sed -i.bak -e "s/\"lib-jitsi-meet.*/\"lib-jitsi-meet\"\: \"${LIB_JITSI_MEET_PKG}\",/g" package.json
83
+    echo "Package.json lib-jitsi-meet line:"
84
+    grep lib-jitsi-meet package.json
85
+else
86
+    echo "LIB_JITSI_MEET_PKG var not set - will not modify the package.json"
87
+fi
88
+
89
+git log -20 --graph --pretty=format':%C(yellow)%h%Cblue%d%Creset %s %C(white) %an, %ar%Creset'
90
+
91
+# certificates
92
+
93
+CERT_DIR="ios/travis-ci/certs"
94
+
95
+mkdir $CERT_DIR
96
+
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}/id_rsa.enc ${DEPLOY_SSH_CERT_URL}
102
+
103
+openssl aes-256-cbc -k "$ENCRYPTION_PASSWORD" -in ${CERT_DIR}/dev-cert.cer.enc -d -a -out ${CERT_DIR}/dev-cert.cer
104
+openssl aes-256-cbc -k "$ENCRYPTION_PASSWORD" -in ${CERT_DIR}/dev-key.p12.enc -d -a -out ${CERT_DIR}/dev-key.p12
105
+openssl aes-256-cbc -k "$ENCRYPTION_PASSWORD" -in ${CERT_DIR}/dev-profile.mobileprovision.enc -d -a -out ${CERT_DIR}/dev-profile.mobileprovision
106
+openssl aes-256-cbc -k "$ENCRYPTION_PASSWORD" -in ${CERT_DIR}/id_rsa.enc -d -a -out ${CERT_DIR}/id_rsa
107
+chmod 0600 ${CERT_DIR}/id_rsa
108
+
109
+security create-keychain -p $ENCRYPTION_PASSWORD ios-build.keychain
110
+security default-keychain -s ios-build.keychain
111
+security unlock-keychain -p $ENCRYPTION_PASSWORD ios-build.keychain
112
+security set-keychain-settings -t 3600 -l ~/Library/Keychains/ios-build.keychain
113
+
114
+echo "importing Apple cert"
115
+security import ${CERT_DIR}/AppleWWDRCA.cer -k ios-build.keychain -A
116
+echo "importing dev-cert.cer"
117
+security import ${CERT_DIR}/dev-cert.cer -k ios-build.keychain -A
118
+echo "importing dev-key.p12"
119
+security import ${CERT_DIR}/dev-key.p12 -k ios-build.keychain -P $IOS_SIGNING_CERT_PASSWORD -A
120
+
121
+echo "will set-key-partition-list"
122
+# Fix for OS X Sierra that hungs in the codesign step
123
+security set-key-partition-list -S apple-tool:,apple: -s -k $ENCRYPTION_PASSWORD ios-build.keychain > /dev/null
124
+echo "done set-key-partition-list"
125
+
126
+mkdir -p ~/Library/MobileDevice/Provisioning\ Profiles
127
+
128
+cp "${CERT_DIR}/dev-profile.mobileprovision"  ~/Library/MobileDevice/Provisioning\ Profiles/
129
+
130
+npm install
131
+
132
+cd ios
133
+pod install
134
+cd ..
135
+
136
+mkdir -p /tmp/jitsi-meet/
137
+
138
+xcodebuild archive -workspace ios/jitsi-meet.xcworkspace -scheme jitsi-meet -configuration Release -archivePath /tmp/jitsi-meet/jitsi-meet.xcarchive
139
+
140
+sed -e "s/YOUR_TEAM_ID/${IOS_TEAM_ID}/g" ios/travis-ci/build-ipa.plist.template > ios/travis-ci/build-ipa.plist
141
+
142
+IPA_EXPORT_DIR=/tmp/jitsi-meet/jitsi-meet-ipa
143
+
144
+xcodebuild -exportArchive -archivePath /tmp/jitsi-meet/jitsi-meet.xcarchive -exportPath $IPA_EXPORT_DIR  -exportOptionsPlist ios/travis-ci/build-ipa.plist
145
+
146
+echo "Will try deploy the .ipa to: ${IPA_DEPLOY_LOCATION}"
147
+
148
+scp -i ${CERT_DIR}/id_rsa -o StrictHostKeyChecking=no -o LogLevel=DEBUG "${IPA_EXPORT_DIR}/jitsi-meet.ipa" "${IPA_DEPLOY_LOCATION}"

Loading…
取消
儲存