-
Notifications
You must be signed in to change notification settings - Fork 22
/
releaseUpgrade.sh
executable file
·63 lines (48 loc) · 1.74 KB
/
releaseUpgrade.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
#!/usr/bin/env bash
# exit when any command fails
set -e
LIB_DIR="lib"
JAR_PREFIX="ant-salesforce"
OLD_JAR=$(basename $LIB_DIR/$JAR_PREFIX*.jar)
MAJOR_VERSION_NUMBER=$(echo $OLD_JAR | sed "s/$JAR_PREFIX-\([0-9]\+\).0.jar/\1/g")
OLD_API_VERSION="$MAJOR_VERSION_NUMBER.0"
NEW_API_VERSION="$(( MAJOR_VERSION_NUMBER + 1 )).0"
NEW_JAR="$JAR_PREFIX-$NEW_API_VERSION.jar"
read -p "Upgrade Salesforce API version from $OLD_API_VERSION to $NEW_API_VERSION? " -n 1 -r
echo
if [[ ! $REPLY =~ ^[Yy]$ ]]; then
echo "Skipped."
exit 1
fi
## Download new ant lib jar and replace old one
ANT_ZIP_URL="https://gs0.salesforce.com/dwnld/SfdcAnt/salesforce_ant_$NEW_API_VERSION.zip"
ANT_ZIP="ant.zip"
JAR="$JAR_PREFIX.jar"
curl $ANT_ZIP_URL --output $ANT_ZIP
unzip -j $ANT_ZIP $JAR -d $LIB_DIR
mv $LIB_DIR/$JAR $LIB_DIR/$NEW_JAR
rm $ANT_ZIP
## Update API version in files
BUILD_XML_FILE="build.xml"
GROOVY_FILE="force-meta-backup.groovy"
sed -i "s/\(salesforce.antlib.version\" value=\"\)$OLD_API_VERSION\"/\1$NEW_API_VERSION\"/g" $BUILD_XML_FILE
sed -i "s/\(version='\)$MAJOR_VERSION_NUMBER\..*'/\1$NEW_API_VERSION.0'/g" $GROOVY_FILE
## Update
git rm $LIB_DIR/$OLD_JAR
git add $LIB_DIR/$NEW_JAR $BUILD_XML_FILE $GROOVY_FILE
echo ""
echo "********************************************************************************"
echo ""
echo "Salesforce Ant lib upgraded from $OLD_API_VERSION to $NEW_API_VERSION"
echo ""
echo "API version number updated in following files:"
echo " - $BUILD_XML_FILE"
echo " - $GROOVY_FILE"
echo ""
echo "Changes have been staged in git for commit"
echo ""
echo "Manually apply any required changes to $GROOVY_FILE to support "
echo "new Metadata types introduced in this release (see release notes)"
echo ""
echo "Test >> Commit >> Done"
echo ""