-
Notifications
You must be signed in to change notification settings - Fork 0
/
step.sh
executable file
·226 lines (178 loc) · 6.12 KB
/
step.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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
#!/bin/bash
# Do not exit on errors. If "safe mode" is not enabled it will exit properly at the end.
set +e
# ----------------------
# Advanced configuration
# ----------------------
# shellcheck disable=SC2154
if [[ "${debug}" == "true" || "${debug}" == "yes" ]]; then
set -x
fi
entry_file="${entry_file:-${ENTRY_FILE}}"
if [[ -n ${entry_file} ]]; then
export ENTRY_FILE="${entry_file}"
fi
# Build command arguments
args=("ios")
args+=("--output-format" "json")
args+=("--repo-path" "${BITRISE_SOURCE_DIR}")
api_key="${api_key:-${NITRO_API_KEY}}"
args+=("--api-key" "${api_key}")
# -------------------
# Basic configuration
# -------------------
if [[ -n ${root_directory} ]]; then
args+=("--root-directory" "${root_directory}")
fi
if [[ -n ${scheme} ]]; then
args+=("--scheme" "${scheme}")
fi
if [[ -n ${xcconfig_path} ]]; then
args+=("--xcconfig-path" "${xcconfig_path}")
fi
if [[ -n ${build_configuration} ]]; then
args+=("--build-configuration" "${build_configuration}")
fi
# --------------
# App Versioning
# --------------
if [[ -n ${version_name} ]]; then
args+=("--version-name" "${version_name}")
fi
if [[ -n ${version_code} ]]; then
args+=("--version-code" "${version_code}")
fi
# shellcheck disable=SC2154
if [[ "${disable_version_name_from_package_json}" == "true" || "${disable_version_name_from_package_json}" == "yes" ]]; then
args+=("--disable-version-name-from-package-json")
fi
# shellcheck disable=SC2154
if [[ "${disable_version_code_auto_generation}" == "true" || "${disable_version_code_auto_generation}" == "yes" ]]; then
args+=("--disable-version-code-auto-generation")
fi
# -----------
# App Signing
# -----------
if [[ -n ${certificate_url} ]]; then
args+=("--certificate-url" "${certificate_url}")
fi
if [[ -n ${certificate_passphrase} ]]; then
args+=("--certificate-passphrase" "${certificate_passphrase}")
fi
if [[ -n ${codesigning_identity} ]]; then
args+=("--codesigning-identity" "${codesigning_identity}")
fi
if [[ -n ${provisioning_profile_urls} ]]; then
IFS='|' provisioning_profile_urls_value=("${provisioning_profile_urls}")
# shellcheck disable=SC2206
args+=("--provisioning-profile-urls" ${provisioning_profile_urls_value[@]})
fi
if [[ -n ${provisioning_profile_specifier} ]]; then
args+=("--provisioning-profile-specifier" "${provisioning_profile_specifier}")
fi
if [[ -n ${team_id} ]]; then
args+=("--team-id" "${team_id}")
fi
if [[ -n ${export_method} ]]; then
args+=("--export-method" "${export_method}")
fi
# -------
# Caching
# -------
if [[ -n ${cache_provider} ]]; then
args+=("--cache-provider" "${cache_provider}")
fi
disable_cache="${disable_cache:-${NITRO_DISABLE_CACHE}}"
# shellcheck disable=SC2154
if [[ "${disable_cache}" == "true" || "${disable_cache}" == "yes" ]]; then
args+=("--disable-cache")
fi
if [[ -n ${cache_env_var_lookup_keys} ]]; then
IFS='|' cache_env_var_lookup_keys_value=("${cache_env_var_lookup_keys}")
# shellcheck disable=SC2206
args+=("--cache-env-var-lookup-keys" ${cache_env_var_lookup_keys_value[@]})
fi
if [[ -n ${cache_file_lookup_paths} ]]; then
IFS='|' cache_file_lookup_paths_value=("${cache_file_lookup_paths}")
# shellcheck disable=SC2206
args+=("--cache-file-lookup-paths" ${cache_file_lookup_paths_value[@]})
fi
disable_metro_cache="${disable_metro_cache:-${NITRO_DISABLE_METRO_CACHE}}"
# shellcheck disable=SC2154
if [[ "${disable_metro_cache}" == "true" || "${disable_metro_cache}" == "yes" ]]; then
args+=("--disable-metro-cache")
fi
aws_s3_access_key_id="${aws_s3_access_key_id:-${NITRO_AWS_S3_ACCESS_KEY_ID}}"
if [[ -n ${aws_s3_access_key_id} ]]; then
args+=("--aws-s3-access-key-id" "$aws_s3_access_key_id")
fi
aws_s3_secret_access_key="${aws_s3_secret_access_key:-${NITRO_AWS_S3_SECRET_ACCESS_KEY}}"
if [[ -n ${aws_s3_secret_access_key} ]]; then
args+=("--aws-s3-secret-access-key" "$aws_s3_secret_access_key")
fi
aws_s3_region="${aws_s3_region:-${NITRO_AWS_S3_REGION}}"
if [[ -n ${aws_s3_region} ]]; then
args+=("--aws-s3-region" "$aws_s3_region")
fi
aws_s3_bucket="${aws_s3_bucket:-${NITRO_AWS_S3_BUCKET}}"
if [[ -n ${aws_s3_bucket} ]]; then
args+=("--aws-s3-bucket" "$aws_s3_bucket")
fi
# -----
# Hooks
# -----
if [[ -n ${pre_install_command} ]]; then
args+=("--pre-install-command" "${pre_install_command}")
fi
if [[ -n ${pre_build_command} ]]; then
args+=("--pre-build-command" "${pre_build_command}")
fi
if [[ -n ${post_build_command} ]]; then
args+=("--post-build-command" "${post_build_command}")
fi
# --------
# Advanced
# --------
if [[ -n ${detox_configuration} ]]; then
args+=("--detox-configuration" "${detox_configuration}")
fi
output_directory="${output_directory:-${BITRISE_DEPLOY_DIR}}"
if [[ -n ${output_directory} ]]; then
args+=("--output-directory" "${output_directory}")
fi
# shellcheck disable=SC2154
if [[ "${verbose}" == "true" || "${verbose}" == "yes" ]]; then
args+=("--verbose")
fi
# -------------------
# Nitro Cli execution
# -------------------
NITRO_OUTPUT_JSON_PATH="$(pwd)/nitro-output.json"
npx @nitro-build/cli@^0.11.0 "${args[@]}"
exit_code=$?
# Set environment variables using envman
if [[ exit_code -ne 0 ]]; then
envman add --key "NITRO_BUILD_STATUS" --value "failed"
else
envman add --key "NITRO_BUILD_STATUS" --value "success"
fi
if [ -f "${NITRO_OUTPUT_JSON_PATH}" ]; then
output=$(cat < "${NITRO_OUTPUT_JSON_PATH}")
echo "${output}" | jq -r '.appPath' | xargs -I{} echo -n {} | envman add --key NITRO_APP_PATH
echo "${output}" | jq -r '.outputDir' | xargs -I{} echo -n {} | envman add --key NITRO_OUTPUT_DIR
echo "${output}" | jq -r '.summaryPath' | xargs -I{} echo -n {} | envman add --key NITRO_SUMMARY_PATH
echo "${output}" | jq -r '.logsPath' | xargs -I{} echo -n {} | envman add --key NITRO_LOGS_PATH
else
echo "File not found: ${NITRO_OUTPUT_JSON_PATH}"
fi
fail_safe="${fail_safe:-${FAIL_SAFE}}"
# shellcheck disable=SC2154
if [[ "${fail_safe}" == "true" || "${fail_safe}" == "yes" ]]; then
if [[ exit_code -ne 0 ]]; then
echo "⚠️ Nitro has thrown a '${exit_code}' error code while running on fail-safe mode. You can check 'NITRO_BUILD_STATUS' value in further steps."
fi
else
# If not running in "safe mode" exit with captured exit_code
set -e
exit $exit_code
fi