-
Notifications
You must be signed in to change notification settings - Fork 0
/
release-spec.sh
101 lines (88 loc) · 3.42 KB
/
release-spec.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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
#!/usr/bin/env bash
RELEASE_VERSION=$1
VERSION_FAMILY=$2
RELEASE_VERSION_QUALIFIER=$3
DELIVERY_QUALIFIER=$4
NEW_VERSION=$5
BRANCH=$6
PUSH_CHANGES=${7:-false}
WORKSPACE=${WORKSPACE:-'.'}
if [ -z "$RELEASE_VERSION" ]; then
echo "ERROR: Release version argument not supplied"
exit 1
fi
if [ -z "$VERSION_FAMILY" ]; then
echo "ERROR: Version family argument not supplied"
exit 1
fi
if [ -z "$NEW_VERSION" ]; then
echo "ERROR: New version argument not supplied"
exit 1
fi
if [ -z "$BRANCH" ]; then
echo "ERROR: Branch argument not supplied"
exit 1
fi
if [ -z "$DELIVERY_QUALIFIER" ]; then
echo "ERROR: Delivery qualifier not supplied, use '-' if you don't want a delivery"
exit 1
fi
pushd ${WORKSPACE}
# Update the versions in the build.xml file
sed -i 's@<property name="bv\.version" value=".*" />@<property name="bv.version" value="'${RELEASE_VERSION}'" />@' build.xml
if [ ! -z "$RELEASE_VERSION_QUALIFIER" ]; then
# there is an issue with this specific expression if passed directly to sed
sed_expression='s@<property name="bv\.version\.qualifier" value=".*" />@<property name="bv.version.qualifier" value=" ('${RELEASE_VERSION_QUALIFIER}')" />@'
sed -i "${sed_expression}" build.xml
fi
sed -i 's@<property name="bv\.revdate" value=".*" />@<property name="bv.revdate" value="'$(date +%Y-%m-%d)'" />@' build.xml
git add build.xml
git commit -m "[Jenkins release job] Preparing release $RELEASE_VERSION"
git tag $RELEASE_VERSION
# Generate the specification
ant all.doc
# Clone the website and push the generated specification to the website
git clone [email protected]:beanvalidation/beanvalidation.org.git
pushd beanvalidation.org
git checkout production
SPEC_DIR=${VERSION_FAMILY}/spec
VERSION_DIR=${SPEC_DIR}/${RELEASE_VERSION,,}
mkdir -p ${VERSION_DIR}
cp -f ../target/html/index.html ${SPEC_DIR}/
cp -f ../target/html/index.html ${VERSION_DIR}/
cp -f ../target/pdf/index.pdf ${SPEC_DIR}/bean-validation-specification.pdf
cp -f ../target/pdf/index.pdf ${VERSION_DIR}/bean-validation-specification.pdf
git add ${SPEC_DIR}
git commit -m "[Jenkins release job] Release specification $RELEASE_VERSION"
popd
# Go back to a snapshot version
sed -i 's@<property name="bv\.version" value=".*" />@<property name="bv.version" value="'${NEW_VERSION}'" />@' build.xml
sed -i 's@<property name="bv\.version\.qualifier" value=".*" />@<property name="bv.version.qualifier" value="" />@' build.xml
sed -i 's@<property name="bv\.revdate" value=".*" />@<property name="bv.revdate" value="${current.date}" />@' build.xml
# Prepare next development iteration
git add build.xml
git commit -m "[Jenkins release job] Preparing next development iteration"
# Push the changes if required
if [ "$PUSH_CHANGES" = true ] ; then
echo "Pushing changes to the upstream repository."
git push origin $BRANCH
git push origin $RELEASE_VERSION
echo "Pushing changes to the upstream beanvalidation.org repository."
pushd beanvalidation.org
git push origin production
popd
else
echo "WARNING: Not pushing changes to the upstream repository."
fi
# build the delivery if a delivery version is provided
if [ "$DELIVERY_QUALIFIER" != "-" ]; then
mkdir -p target/delivery
pushd target/delivery
NAME="bean_validation-${RELEASE_VERSION//./_}-${DELIVERY_QUALIFIER}-spec"
mkdir -p ${NAME}/{pdf,html}
cp -a ../html/index.html ${NAME}/html/${NAME}.html
cp -a ../pdf/index.pdf ${NAME}/pdf/${NAME}.pdf
zip -r ${NAME}.zip ${NAME}
popd
fi
popd