-
Notifications
You must be signed in to change notification settings - Fork 223
Expand file tree
/
Copy pathset_version
More file actions
executable file
·64 lines (52 loc) · 1.59 KB
/
set_version
File metadata and controls
executable file
·64 lines (52 loc) · 1.59 KB
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
#!/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
#
cd $(dirname $0)
VERSION=$1
REGEX="^[0-9]+\.[0-9]+\.[0-9]+(-[A-Za-z0-9]+([._-][A-Za-z0-9]+)*)?$"
if [ -z $VERSION ]; then
printf "Missing version ..."
exit 1
elif [[ ! "$1" =~ $REGEX ]]; then
printf "Version format not valid. Valid formats are:\n"
printf " - [0-9].[0-9].[0-9]\n"
printf " - [0-9].[0-9].[0-9]-alpha[.N]\n"
printf " - [0-9].[0-9].[0-9]-beta[.N]\n"
printf " - [0-9].[0-9].[0-9]-rc[.N]\n"
printf " - [0-9].[0-9].[0-9]-SNAPSHOT_[git_sha]\n"
exit 1
else
# Call main
main $VERSION
exit 0
fi