-
Notifications
You must be signed in to change notification settings - Fork 220
/
Copy pathset_version
executable file
·58 lines (46 loc) · 1.41 KB
/
set_version
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
#!/usr/bin/env bash
#
# Function definitions
#
function update_version() {
VERSION="$1"
PARENT_POM="pom.xml"
POMS=("client/deploy-resources/gnu_pom.xml" "client/deploy-resources/bouncycastle_pom.xml")
for PUBLIC_POM in "${POMS[@]}"; do
# Detecting host type. `sed` on bsd and linux are not the same
if [[ "$(uname)" == "Darwin" ]]; then
sed -i "" "s#<revision>[^<]*</revision>#<revision>${VERSION}</revision>#g" "$PARENT_POM"
sed -i "" "1,/<version>[^<]*<\/version>/ s#<version>[^<]*</version>#<version>${VERSION}</version>#" "$PUBLIC_POM"
else
sed -i "s#<revision>[^<]*</revision>#<revision>${VERSION}</revision>#g" "$PARENT_POM"
sed -i "0,/<version>[^<]*<\/version>/ s//<version>${VERSION}<\/version>/" "$PUBLIC_POM"
fi
done
}
function main() {
VERSION=$1
BUILD_TYPE=$2
# If version has been set using set_crypto we are honoring that setting
if [ -f "bouncycastle.config" ]; then
BUILD_TYPE="bouncycastle"
elif [ -f "gnu.config" ]; then
BUILD_TYPE="gnu"
fi
update_version $VERSION $BUILD_TYPE
}
#
# Main entry
#
VERSION=$1
REGEX="^[0-9]+\.[0-9]+\.[0-9]+(-SNAPSHOT_[a-zA-Z0-9]+)?$"
if [ -z $VERSION ]; then
printf "Missing version ..."
exit 1
elif [[ ! "$1" =~ $REGEX ]]; then
printf "Version format not valid. Valid format are [0 - 9].[0 - 9].[0 - 9] | [0 - 9].[0 - 9].[0 - 9]-SNAPSHOT_[git_sha]"
exit 1
else
# Call main
main $VERSION
exit 0
fi