forked from num42/n42-buildscripts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
bootstrap.sh
107 lines (82 loc) · 3.1 KB
/
bootstrap.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
#!/bin/sh
# exit script, if error
set -e
# defne colors
RED=`tput setaf 1`
GREEN=`tput setaf 2`
NOCOLOR=`tput sgr0`
BOOTSTRAP_SOURCE="https://raw.githubusercontent.com/num42/n42-ios-bootstrap-shell/master/bootstrap.sh"
echo "${GREEN}Running N42 Bootstrap v1.14 (2017-02-20)${NOCOLOR}"
echo "${GREEN}If the script fails, there might be a newer Version on $BOOTSTRAP_SOURCE ${NOCOLOR}"
echo "${GREEN}You can directly download it with 'curl -L $BOOTSTRAP_SOURCE -o bootstrap.sh' ${NOCOLOR}"
echo "${GREEN}You can update the script by running "sh bootstrap.sh -u"' ${NOCOLOR}"
if [[ $1 == "-u" ]] ; then
echo ""
echo "${GREEN} Updating bootstrap.sh ${NOCOLOR}";
curl -L $BOOTSTRAP_SOURCE?$(date +%s) -o $0
exit 1
fi
# Guard to update brew only once and only if necessary
NEEDS_TO_UPDATE_BREW=1
installDependencyWithBrew(){
if [ $NEEDS_TO_UPDATE_BREW -eq 1 ]; then
echo ""
echo "${GREEN} UPDATING BREW ${NOCOLOR}";
# update brew to keep dependencies up to date
brew update || echo "${RED} FAILED TO UPDATE BREW ${NOCOLOR}";
NEEDS_TO_UPDATE_BREW=0
fi
echo ""
echo "${GREEN} INSTALLING $1 WITH BREW ${NOCOLOR}";
# install dependency, if is not installed
brew list $1 || brew install $1 || echo "${RED} FAILED TO INSTALL $1 ${NOCOLOR}";
# upgrade dependency, if it is outdated
brew outdated $1 || brew upgrade $1 || echo "${RED} FAILED TO UPGRADE $1 ${NOCOLOR}";
}
if [ -e ".ruby-version" ]; then
echo ""
echo "${GREEN} SETTING UP RUBY ${NOCOLOR}";
installDependencyWithBrew rbenv
installDependencyWithBrew ruby-build
# install ruby version from .ruby-version, skipping if already installed (-s)
rbenv install -s
fi
if [ -e "Gemfile" ]; then
echo ""
echo "${GREEN} INSTALLING GEMS ${NOCOLOR}";
# install bundler gem for ruby dependency management
gem install bundler || echo "${RED} FAILED TO INSTALL BUNDLER ${NOCOLOR}";
bundle install || echo "${RED} FAILED TO INSTALL BUNDLE ${NOCOLOR}";
fi
if [ -e "podfile" ]; then
echo ""
echo "${GREEN} RUNNING COCOAPODS ${NOCOLOR}";
# install cocoapods dependencies
bundle exec pod repo update
bundle exec pod install || echo "${RED} FAILED TO INSTALL PODS ${NOCOLOR}";
fi
if [ -e "Cartfile" ]; then
echo ""
echo "${GREEN} INSTALLING CARTHAGE ${NOCOLOR}";
installDependencyWithBrew carthage
fi
if [ -e ".gitmodules" ]; then
echo ""
echo "${GREEN} SETTING UP GITMODULES ${NOCOLOR}";
# keep submodules up to date, see https://git-scm.com/book/en/v2/Git-Tools-Submodules
git submodule init || echo "${RED} FAILED TO INIT SUBMODULES ${NOCOLOR}";
git submodule update || echo "${RED} FAILED TO UPDATE SUBMODULES ${NOCOLOR}";
fi
if [ -e "fastlane/Fastfile" ]; then
if bundle exec fastlane lanes | grep "match_all"; then
echo ""
echo "${GREEN} SYNCING CERTIFICATES AND PROFILES ${NOCOLOR}";
# Run fastlane to ensure certs and profiles are installed
bundle exec fastlane ios match_all || echo "${RED} FAILED TO RUN MATCH ${NOCOLOR}";
fi
fi
if [ -e "bootstrap-specialized.sh" ]; then
echo ""
echo "${GREEN} RUNNING SPECIALIZED BOOTSTRAP SCRIPT ${NOCOLOR}";
source bootstrap-specialized.sh
fi