-
Notifications
You must be signed in to change notification settings - Fork 0
/
appcenter-pre-build.sh
executable file
·62 lines (50 loc) · 1.83 KB
/
appcenter-pre-build.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
#!/usr/bin/env bash
#
# For Xamarin, change some constants located in some class of the app.
# In this sample, suppose we have an AppConstant.cs class in shared folder with follow content:
#
# namespace Core
# {
# public class AppConstant
# {
# public const string ApiUrl = "https://production.com/api";
# }
# }
#
# Suppose in our project exists two branches: master and develop.
# We can release app for production API in master branch and app for test API in develop branch.
# We just need configure this behaviour with environment variable in each branch :)
#
# The same thing can be perform with any class of the app.
#
# AN IMPORTANT THING: FOR THIS SAMPLE YOU NEED DECLARE API_URL ENVIRONMENT VARIABLE IN APP CENTER BUILD CONFIGURATION.
if [ ! -n "$APP_CENTER_SETTING" ]
then
echo "You need define the APP_CENTER_SETTING variable in App Center"
exit
fi
APP_CONSTANT_FILE=$APPCENTER_SOURCE_DIRECTORY/ObjectDetector/AppConstants.cs
if [ -e "$APP_CONSTANT_FILE" ]
then
echo "Updating AppCenterKey to $APP_CENTER_SETTING in AppConstants.cs"
sed -i '' 's#AppCenterKey = "ios="#AppCenterKey = "ios='$APP_CENTER_SETTING'"#' $APP_CONSTANT_FILE
echo "File content:"
cat $APP_CONSTANT_FILE
fi
INFO_PLIST_FILE=$APPCENTER_SOURCE_DIRECTORY/ObjectDetector.iOS/Info.plist
if [ -e "$INFO_PLIST_FILE" ]
then
echo "Updating AppCenterKey to $APP_CENTER_SETTING in Info.plist"
sed -i '' 's#appcenter-distributionkey#appcenter-'$APP_CENTER_SETTING'#' $INFO_PLIST_FILE
echo "File content:"
cat $INFO_PLIST_FILE
fi
GOOGLE_JSON_FILE=$APPCENTER_SOURCE_DIRECTORY/ObjectDetector.Android/google-services.json
if [ -e "$GOOGLE_JSON_FILE" ]
then
echo "Updating Google Json"
echo "$GOOGLE_JSON" > $GOOGLE_JSON_FILE
sed -i -e 's/\\"/'\"'/g' $GOOGLE_JSON_FILE
echo "File content:"
cat $GOOGLE_JSON_FILE
fi