Skip to content

Commit 466b41b

Browse files
author
Guido Marucci Blas
committed
Updates build scripts.
1 parent b77904b commit 466b41b

File tree

7 files changed

+105
-94
lines changed

7 files changed

+105
-94
lines changed

script/.env

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
1+
REQUIRED_CARTHAGE_VERSION=0.9.2
22
PROJECT_NAME=ReactiveArray
33
XCODE_SCHEME=ReactiveArray
44
XCODE_WORKSPACE=

script/bootstrap

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ bundle_install ()
8787
"or try to install the gems globally by running the following command:"
8888
print_gem_install_cmd
8989
printf "\033[0m"
90+
exit 1
9091
fi
9192
}
9293

@@ -165,6 +166,21 @@ install_dependencies ()
165166
fi
166167
}
167168

169+
install_carthage ()
170+
{
171+
source script/common/carthage
172+
173+
if type carthage > /dev/null
174+
then
175+
echo ""
176+
echo " → Checking installed version of carthage"
177+
echo ""
178+
check_carthage_version
179+
else
180+
force_install_carthage
181+
fi
182+
}
183+
168184
main ()
169185
{
170186
source script/.env
@@ -178,7 +194,7 @@ main ()
178194

179195
if [ -f Cartfile ]
180196
then
181-
brew_install "carthage"
197+
install_carthage
182198
bootstrap_carthage
183199
fi
184200

script/build

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,11 @@
22

33
set -e
44

5+
source script/common/carthage
6+
57
build_using_carthage ()
68
{
9+
check_carthage_version
710
carthage_cmd="carthage build --no-skip-current --platform ios"
811
if [ "$USE_SSH" == "true" ]
912
then

script/cibuild

Lines changed: 23 additions & 92 deletions
Original file line numberDiff line numberDiff line change
@@ -1,99 +1,30 @@
11
#!/bin/bash
22

3-
export SCRIPT_DIR=$(dirname "$0")
4-
5-
##
6-
## Configuration Variables
7-
##
8-
9-
# The name of the keychain to create for iOS code signing.
10-
KEYCHAIN=ios-build.keychain
11-
12-
##
13-
## Build Process
14-
##
15-
16-
main ()
17-
{
18-
if [ -f Cartfile ]
19-
then
20-
echo ""
21-
echo "####### Importing Developer Certificates #######"
22-
echo ""
23-
import_certs
24-
fi
25-
26-
echo ""
27-
echo "####### Bootstrap Phase #######"
28-
echo ""
29-
script/bootstrap
30-
local status=$?
31-
32-
if [ $status -eq 0 ]
3+
echo ""
4+
echo "####### Bootstrap Phase #######"
5+
echo ""
6+
NO_CARTHAGE_UPDATE=true script/bootstrap
7+
status=$?
8+
9+
if [ $status -eq 0 ]
10+
then
11+
echo ""
12+
echo ""
13+
echo "####### Build & Test Phase #######"
14+
echo ""
15+
set -o pipefail && script/test 2>&1 | tee /tmp/build.test-output.txt
16+
status=$?
17+
if [ ! $status -eq 0 ]
18+
then
19+
log_file_path=`cat /tmp/build.test-output.txt | tail -n 100 | perl -l -ne '/(\/var\/folders.*\/com\.apple\.dt\.XCTest-status.*)\)/ && print $1'`
20+
if [ ! -z "$log_file_path" ]
3321
then
3422
echo ""
23+
echo " → The tests have failed. Printing output of log file '$log_file_path'."
24+
cat $log_file_path
3525
echo ""
36-
echo "####### Build & Test Phase #######"
37-
echo ""
38-
set -o pipefail && script/test 2>&1 | tee /tmp/build.test-output.txt
39-
status=$?
40-
if [ ! $status -eq 0 ]
41-
then
42-
log_file_path=`cat /tmp/build.test-output.txt | tail -n 100 | perl -l -ne '/(\/var\/folders.*\/com\.apple\.dt\.XCTest-status.*)\)/ && print $1'`
43-
if [ ! -z "$log_file_path" ]
44-
then
45-
echo ""
46-
echo " → The tests have failed. Printing output of log file '$log_file_path'."
47-
cat $log_file_path
48-
echo ""
49-
fi
50-
fi
51-
fi
52-
53-
delete_keychain
54-
exit $status
55-
}
56-
57-
import_certs ()
58-
{
59-
# If this environment variable is missing, we must not be running on Travis.
60-
if [ -z "$KEY_PASSWORD" ]
61-
then
62-
return 0
63-
fi
64-
65-
echo " → Setting up code signing..."
66-
local password=cibuild
67-
68-
# Create a temporary keychain for code signing.
69-
security create-keychain -p "$password" "$KEYCHAIN"
70-
security default-keychain -s "$KEYCHAIN"
71-
security unlock-keychain -p "$password" "$KEYCHAIN"
72-
security set-keychain-settings -t 3600 -l "$KEYCHAIN"
73-
74-
# Download the certificate for the Apple Worldwide Developer Relations
75-
# Certificate Authority.
76-
local certpath="$SCRIPT_DIR/apple_wwdr.cer"
77-
curl -s 'https://developer.apple.com/certificationauthority/AppleWWDRCA.cer' > "$certpath"
78-
security import "$certpath" -k "$KEYCHAIN" -T /usr/bin/codesign
79-
80-
# Import our development certificate.
81-
security import "$SCRIPT_DIR/certificates/cibot.p12" -k "$KEYCHAIN" -P "$KEY_PASSWORD" -T /usr/bin/codesign
82-
}
83-
84-
delete_keychain ()
85-
{
86-
if [ -z "$KEY_PASSWORD" ]
87-
then
88-
return 0
8926
fi
27+
fi
28+
fi
9029

91-
echo " → Removing temporary keychain"
92-
security delete-keychain "$KEYCHAIN"
93-
echo " ✔ Temporary keychain successfully removed."
94-
}
95-
96-
export -f import_certs
97-
export -f delete_keychain
98-
99-
main
30+
exit $status

script/common/carthage

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
force_install_carthage ()
2+
{
3+
echo ""
4+
echo " → Installing carthage '$REQUIRED_CARTHAGE_VERSION'"
5+
echo ""
6+
curl -s -L -O https://github.com/Carthage/Carthage/releases/download/$REQUIRED_CARTHAGE_VERSION/Carthage.pkg > /dev/null
7+
sudo installer -pkg Carthage.pkg -target / > /dev/null
8+
rm Carthage.pkg
9+
echo " ✔ carthage '$REQUIRED_CARTHAGE_VERSION' successfully installed"
10+
echo ""
11+
}
12+
13+
uninstall_carthage ()
14+
{
15+
echo ""
16+
echo " → Uninstalling carthage"
17+
echo ""
18+
local carthage_installed_version=`carthage version`
19+
if type brew > /dev/null && [ ! -z "$(brew list --versions carthage)" ]
20+
then
21+
brew uninstall carthage > /dev/null
22+
else
23+
sudo rm -frd /Library/Frameworks/CarthageKit.framework
24+
sudo rm /usr/local/bin/carthage
25+
fi
26+
echo " ✔ carthage '$carthage_installed_version' successfully uninstalled"
27+
}
28+
29+
check_carthage_version ()
30+
{
31+
local carthage_installed_version=`carthage version`
32+
if [ "$carthage_installed_version" != "$REQUIRED_CARTHAGE_VERSION" ]
33+
then
34+
printf "\033[1;31mError: carthage version '$carthage_installed_version' is not equal to '$REQUIRED_CARTHAGE_VERSION'"
35+
printf "\033[0m"
36+
if [ ! -z "$NO_CARTHAGE_UPDATE" ]
37+
then
38+
exit 1
39+
else
40+
echo ""
41+
echo ""
42+
echo "Would you like to update carthage to version '$REQUIRED_CARTHAGE_VERSION'? [N/y]"
43+
read update_carthage
44+
if [ "$update_carthage" == "y" ]
45+
then
46+
uninstall_carthage
47+
force_install_carthage
48+
else
49+
exit 1
50+
fi
51+
fi
52+
fi
53+
}

script/test

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ set -e
44

55
source script/.env
66
source script/script_hooks/schemes
7+
source script/common/carthage
78

89
run_tests ()
910
{
@@ -38,6 +39,11 @@ run_tests ()
3839
eval $test_command
3940
}
4041

42+
if [ -f Cartfile ]
43+
then
44+
check_carthage_version
45+
fi
46+
4147
current_schemes=$(schemes)
4248
if [ -z "$current_schemes" ]
4349
then

script/update

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,11 @@
33
set -e
44

55
source script/.env
6+
source script/common/carthage
67

78
if [ -f Cartfile ] && type carthage > /dev/null
89
then
10+
check_carthage_version
911
carthage_cmd="carthage update --platform ios"
1012
if [ "$USE_SSH" == "true" ]
1113
then

0 commit comments

Comments
 (0)