-
Notifications
You must be signed in to change notification settings - Fork 26
/
set-version.sh
executable file
·58 lines (45 loc) · 1.86 KB
/
set-version.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
#!/bin/bash
if [ $# -eq 1 ]
then
IFS=-
read version flavour <<< "$1"
echo "setting version=$version${flavour:+ with }$flavour"
sed -i -E \
-e "s%^( <version>)[^-]+-([^-]+).*(</version>)$%\1$version-\2${flavour:+-}$flavour\3%" \
pom.xml
version=$(grep -m 1 version pom.xml | sed "s/\s*<[^>]*>\s*//g")
sed -i -E \
-e "s/(jar_version *= *).*/\1'$version'/" \
python/setup.py
elif [ $# -eq 2 ]
then
spark=$1
scala=$2
spark_compat=${spark%.*}
scala_compat=${scala%.*}
spark_major=${spark_compat%.*}
scala_major=${scala_compat%.*}
spark_minor=${spark_compat/*./}
scala_minor=${scala_compat/*./}
spark_patch=${spark/*./}
scala_patch=${scala/*./}
echo "setting spark=$spark and scala=$scala"
sed -i -E \
-e "s%^( <artifactId>)([^_]+)[_0-9.]+(</artifactId>)$%\1\2_${scala_compat}\3%" \
-e "s%^( <version>)([^-]+)-[^-]+(.*</version>)$%\1\2-$spark_compat\3%" \
-e "s%^( <scala.major.version>).+(</scala.major.version>)$%\1${scala_major}\2%" \
-e "s%^( <scala.minor.version>).+(</scala.minor.version>)$%\1${scala_minor}\2%" \
-e "s%^( <scala.patch.version>).+(</scala.patch.version>)$%\1${scala_patch}\2%" \
-e "s%^( <spark.major.version>).+(</spark.major.version>)$%\1${spark_major}\2%" \
-e "s%^( <spark.minor.version>).+(</spark.minor.version>)$%\1${spark_minor}\2%" \
-e "s%^( <spark.patch.version>).+(</spark.patch.version>)$%\1${spark_patch}\2%" \
pom.xml
version=$(grep -m 1 version pom.xml | sed "s/\s*<[^>]*>\s*//g")
sed -i -E \
-e "s/(jar_version *= *).*/\1'$version'/" \
-e "s/(scala_version *= *).*/\1'$scala'/" \
python/setup.py
else
echo "Provide the Spark-Extension version (e.g. 2.5.0 or 2.5.0-SNAPSHOT), or the Spark and Scala version"
exit 1
fi