-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy patheap-xp-version-bump.sh
executable file
·61 lines (48 loc) · 1.61 KB
/
eap-xp-version-bump.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
#!/bin/bash
usage() {
echo "usage: ${0}: [current-version] [next-version]"
}
editFileIfExistWithSED() {
local file="${1}"
local query="${2}"
local statusIfFileMissing="${3:-1}"
if [ -e "${file}" ]; then
sed -i "${file}" -e "${query}"
else
if [ "${statusIfFileMissing}" -ne 0 ]; then
echo "There is no such file '${file}'"
exit "${statusIfFileMissing}"
fi
fi
}
readonly VERSION_SUFFIX=${VERSION_SUFFIX:-'.GA-redhat-SNAPSHOT'}
PREVIOUS_VERSION=${1}
NEXT_VERSION=${2}
if [ -z "${PREVIOUS_VERSION}" ]; then
echo 'Current EAP version not provided - aborting.'
usage
exit 1
fi
if [ -z "${NEXT_VERSION}" ]; then
echo 'Next EAP version not provided - aborting.'
usage
exit 2
fi
readonly JBOSS_EAP_WORKSPACE=${JBOSS_EAP_WORKSPACE:-$(pwd)}
if [ ! -e "${JBOSS_EAP_WORKSPACE}" ] && [ ! -d "${JBOSS_EAP_WORKSPACE}" ]; then
echo "The provided JBOSS_EAP_WORKSPACE does not exists or is not a directory: ${JBOSS_EAP_WORKSPACE}"
echo 'Please provide the appropriate path (or cd to the workspace).'
usage
exit 3
fi
cd "${JBOSS_EAP_WORKSPACE}" > /dev/null || exit
readonly FROM="${PREVIOUS_VERSION}${VERSION_SUFFIX}"
readonly TO="${NEXT_VERSION}${VERSION_SUFFIX}"
echo -n "Updating all pom.xml files from ${FROM} to ${TO}..."
find . -name pom.xml -exec sed -i "s/${FROM}/${TO}/g" '{}' \;
echo 'Done.'
readonly PRODUCT_POM=${PRODUCT_POM:-'./pom.xml'}
readonly PRODUCT_VERSION="${NEXT_VERSION}.GA"
echo -n "Update ${PRODUCT_POM} to XP version ${PRODUCT_VERSION}..."
editFileIfExistWithSED "${PRODUCT_POM}" "s;\(<expansion.pack.release.version>\)[^<]*\(.*$\);\1${PRODUCT_VERSION}\2;"
echo 'Done.'