forked from GoogleCloudPlatform/repository-gardener
-
Notifications
You must be signed in to change notification settings - Fork 0
/
use-latest-deps-ios.sh
executable file
·92 lines (77 loc) · 2.11 KB
/
use-latest-deps-ios.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
#!/usr/bin/env bash
# Copyright 2018 Google Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
print_usage () {
(>&2 echo "Usage:")
(>&2 echo " $0 [-d] github-user/repository-name")
(>&2 echo "Arguments:")
(>&2 echo " -d: do a dry-run. Don't push or send a PR.")
}
# Check for optional arguments.
DRYRUN=0
while getopts :d opt; do
case $opt in
d)
(>&2 echo "Entered dry-run mode.")
DRYRUN=1
;;
\?)
(>&2 echo "Got invalid option -$OPTARG.")
print_usage
exit 1
;;
esac
done
shift $((OPTIND-1))
# Check that positional arguments are set.
if [[ -z $1 ]] ; then
(>&2 echo "Missing repo argument.")
print_usage
exit 1
fi
if [[ "$1" != *"/"* ]] ; then
(>&2 echo "Repo argument needs to be of form username/repo-name.")
print_usage
exit 1
fi
REPO=$1
# Get this script's directory.
# http://stackoverflow.com/a/246128/101923
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
set -e
set -x
set -o pipefail
# Install Ruby
# shellcheck disable=SC1091
source /etc/profile.d/rvm.sh
rvm install 2.6.0
rvm use 2.6.0
# Install gems
gem install bundler
gem install cocoapods
# Find and update each Gemfile.lock
find . -iname Gemfile.lock -execdir bundle update \;
# Update pod source
pod repo update
# Install and uninstall pods for each Podfile to update Podfile.lock
find . -iname Podfile -execdir pod update --no-repo-update \; -execdir pod deintegrate \;
# If there were any changes, test them and then push and send a PR.
set +e
if ! git diff --quiet; then
if [[ "$DRYRUN" -eq 0 ]] ; then
set -e
"${DIR}/commit-and-push.sh"
"${DIR}/send-pr.sh" "$REPO"
fi
fi