-
Notifications
You must be signed in to change notification settings - Fork 388
/
setversion.sh
executable file
·176 lines (145 loc) · 5.22 KB
/
setversion.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
#!/bin/bash
#set -x
OPT_VERSION=""
OPT_CODE=""
OPT_IS_DEV="no"
RED='\033[0;31m'
YELLOW='\033[0;33m'
NC='\033[0m' # No Color
usage ()
{
echo "Use this script to set Mobile SDK version number in source files"
echo "Usage: $0 -v <versionName> -c <versionCode> [-d <isDev>]"
echo " where: versionName is the version name e.g. 7.2.0"
echo " versionCode is the version code e.g. 64"
echo " isDev is yes or no (default) to indicate whether it is a dev build"
}
parse_opts ()
{
while getopts v:c:d: command_line_opt
do
case ${command_line_opt} in
v) OPT_VERSION=${OPTARG};;
c) OPT_CODE=${OPTARG};;
d) OPT_IS_DEV=${OPTARG};;
esac
done
if [ "${OPT_VERSION}" == "" ]
then
echo -e "${RED}You must specify a value for the version name.${NC}"
usage
exit 1
fi
if [ "${OPT_CODE}" == "" ]
then
echo -e "${RED}You must specify a value for the version code.${NC}"
usage
exit 1
fi
}
# Helper functions
update_package_json ()
{
local file=$1
local versionName=$2
gsed -i "s/\"version\":.*\"[^\"]*\"/\"version\": \"${versionName}\"/g" ${file}
}
update_top_build_gradle ()
{
local file=$1
local versionName=$2
gsed -i "s/version = \"[0-9\.]*\"/version = \"${versionName}\"/g" ${file}
}
update_build_gradle ()
{
local file=$1
local versionName=$2
gsed -i "s/\[\"PUBLISH_VERSION\"\] = \"[0-9\.]*\"/\[\"PUBLISH_VERSION\"\] = \"${versionName}\"/g" ${file}
}
update_manifest ()
{
local file=$1
local versionName=$2
local versionCode=$3
gsed -i "s/android\:versionCode=\"[^\"]*\"/android:versionCode=\"${versionCode}\"/g" ${file}
gsed -i "s/android\:versionName=\"[^\"]*\"/android:versionName=\"${versionName}\"/g" ${file}
}
update_config_xml ()
{
local file=$1
local versionName=$2
gsed -i "s/version.*=.*\"[^\"]*\">/version = \"${versionName}\">/g" ${file}
}
update_salesforcesdkmanager_kt ()
{
local file=$1
local versionName=$2
gsed -i "s/SDK_VERSION.*=.*\"[^\"]*\"/SDK_VERSION = \"${versionName}\"/g" ${file}
}
update_generate_doc ()
{
local file=$1
local versionName=$2
gsed -i "s/SalesforceSDK [0-9\.]* API/SalesforceSDK ${versionName} API/g" ${file}
}
update_react_package_json ()
{
local file=$1
local versionName=$2
local isDev=$3
local sdkTag=""
if [ "$OPT_IS_DEV" == "yes" ]
then
sdkTag="dev"
else
sdkTag="v${versionName}"
fi
gsed -i "s/\"version\":.*\"[^\"]*\"/\"version\": \"${versionName}\"/g" ${file}
gsed -i "s/SalesforceMobileSDK-ReactNative.git\#[^\"]*\"/SalesforceMobileSDK-ReactNative.git\#${sdkTag}\"/g" ${file}
}
update_readme ()
{
local file=$1
local version=$2
gsed -i "s/\#\#\# What's New.*/### What's New in ${version}/g" ${file}
gsed -i "s/releases\/tag\/.*[)]/releases\/tag\/v${version}\)/g" ${file}
}
parse_opts "$@"
VERSION_SUFFIXED=""
if [ "$OPT_IS_DEV" == "yes" ]
then
VERSION_SUFFIXED="${OPT_VERSION}.dev"
else
VERSION_SUFFIXED=${OPT_VERSION}
fi
SHORT_VERSION=`echo ${OPT_VERSION} | cut -d. -f1,2`
echo -e "${YELLOW}*** SETTING VERSION NAME TO ${OPT_VERSION}, VERSION CODE TO ${OPT_CODE}, IS DEV = ${OPT_IS_DEV} ***${NC}"
echo "*** Updating main package.json ***"
update_package_json "./package.json" "${OPT_VERSION}"
echo "*** Updating react package.json ***"
update_react_package_json "./libs/SalesforceReact/package.json" "${OPT_VERSION}" "${OPT_IS_DEV}"
echo "*** Updating top build.gradle file ***"
update_top_build_gradle "./build.gradle.kts" "${OPT_VERSION}"
echo "*** Updating build.gradle files ***"
update_build_gradle "./libs/SalesforceAnalytics/build.gradle.kts" "${OPT_VERSION}"
update_build_gradle "./libs/SalesforceSDK/build.gradle.kts" "${OPT_VERSION}"
update_build_gradle "./libs/SmartStore/build.gradle.kts" "${OPT_VERSION}"
update_build_gradle "./libs/MobileSync/build.gradle.kts" "${OPT_VERSION}"
update_build_gradle "./libs/SalesforceHybrid/build.gradle.kts" "${OPT_VERSION}"
update_build_gradle "./libs/SalesforceReact/build.gradle.kts" "${OPT_VERSION}"
echo "*** Updating manifests ***"
update_manifest "./libs/SalesforceAnalytics/AndroidManifest.xml" "${VERSION_SUFFIXED}" "${OPT_CODE}"
update_manifest "./libs/SalesforceSDK/AndroidManifest.xml" "${VERSION_SUFFIXED}" "${OPT_CODE}"
update_manifest "./libs/SmartStore/AndroidManifest.xml" "${VERSION_SUFFIXED}" "${OPT_CODE}"
update_manifest "./libs/MobileSync/AndroidManifest.xml" "${VERSION_SUFFIXED}" "${OPT_CODE}"
update_manifest "./libs/SalesforceHybrid/AndroidManifest.xml" "${VERSION_SUFFIXED}" "${OPT_CODE}"
update_manifest "./libs/SalesforceReact/AndroidManifest.xml" "${VERSION_SUFFIXED}" "${OPT_CODE}"
echo "*** Updating config.xml files ***"
update_config_xml "./libs/SalesforceHybrid/res/xml/config.xml" "${OPT_VERSION}"
update_config_xml "./libs/test/SalesforceHybridTest/res/xml/config.xml" "${OPT_VERSION}"
echo "*** Updating SalesforceSDKManager.kt ***"
update_salesforcesdkmanager_kt "./libs/SalesforceSDK/src/com/salesforce/androidsdk/app/SalesforceSDKManager.kt" "${VERSION_SUFFIXED}"
echo "*** Updating generate_doc.sh ***"
update_generate_doc "./tools/generate_doc.sh" "${SHORT_VERSION}"
echo "*** Updating README.md ***"
update_readme "./README.md" "${OPT_VERSION}"