-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfastlanew
executable file
·92 lines (74 loc) · 2.09 KB
/
fastlanew
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
# NOTE TO USERS:
# AUTO-UPDATED SCRIPT NO NEED TO REVIEW CHANGES! DO NOT CHANGE!
# NOTE TO MAINTAINERS:
# Bump version using release.sh script
readonly VERSION="0.3.2"
readonly LIGHT_RED="\e[91m"
readonly LIGHT_GREEN="\e[92m"
readonly RESET_COLOR="\e[0m"
if ! command -v bundle &> /dev/null; then
echo -e "${LIGHT_RED}>${RESET_COLOR} 'bundle' is not installed." >&2
exit 1
fi
confirm() {
local prompt="$1"
local default=${2:-N}
local values
if [[ "${default}" = 'Y' ]]; then
values='(Y/n)'
else
values='(y/N)'
fi
echo -en "${prompt} ${values}: "
read -rp "" yn <&2
yn=${yn:-$default}
yn=$(echo "$yn" | awk '{print tolower($0)}')
case "${yn}" in
y|yes)
return 0
;;
*)
return 1
;;
esac
}
exec_install() {
bash <(curl -s https://raw.githubusercontent.com/ravnhq/mobile-cicd/main/install.sh)
}
check_auto_update() {
if [[ ! -t 0 ]]; then
echo -e "${LIGHT_GREEN}>${RESET_COLOR} Update check skipped, the terminal is not interactive"
return 0
fi
local version_url='https://raw.githubusercontent.com/ravnhq/mobile-cicd/main/.version'
local remote_version
remote_version=$(curl -s "${version_url}" | sed 's/[[:space:]]//g')
if [[ "${VERSION}" != "${remote_version}" ]]; then
confirm "${LIGHT_GREEN}>${RESET_COLOR} New version available, do you want to update?" 'Y' \
&& exec_install \
&& echo -e "${LIGHT_GREEN}>${RESET_COLOR} Successfully updated, commit your changes before running this again" \
&& exit 0
else
echo -e "${LIGHT_GREEN}>${RESET_COLOR} You're up-to-date!"
fi
}
load_dotenv() {
set -o allexport
# shellcheck disable=SC1090
[[ -f .env ]] && source <(sed -e '/^#/d;/^\s*$/d' -e "s/'/'\\\''/g" -e "s/=\(.*\)/='\1'/g" .env)
set +o allexport
}
update_plugins() {
bundle install &> /dev/null
bundle update fastlane-plugin-ravn_mobile
}
if [[ "$1" == "self-update" ]]; then
echo -e "${LIGHT_GREEN}>${RESET_COLOR} Checking if there's a new update..."
check_auto_update || true
exit 0
fi
check_auto_update || true
load_dotenv
update_plugins
bundle exec fastlane "$@"