forked from sumaris-net/sumaris-pod
-
Notifications
You must be signed in to change notification settings - Fork 0
/
release.sh
executable file
·101 lines (80 loc) · 2.3 KB
/
release.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
#!/bin/bash
mkdir -p .local
RELEASE_OPTS="-DskipTests"
# Rollback previous release, if need
if [[ -f "pom.xml.releaseBackup" ]]; then
echo "**********************************"
echo "* Rollback previous release..."
echo "**********************************"
result=`mvn release:rollback`
failure=`echo "$result" | grep -m1 -P "\[INFO\] BUILD FAILURE" | grep -oP "BUILD \w+"`
# rollback failed
if [[ ! "_$failure" = "_" ]]; then
echo "$result" | grep -P "\[ERROR\] "
exit 1
fi
echo "Rollback previous release [OK]"
fi
echo "**********************************"
echo "* Preparing release..."
echo "**********************************"
mvn release:prepare -Darguments="${RELEASE_OPTS}"
if [[ $? -ne 0 ]]; then
exit 1
fi
echo "Prepare release [OK]"
echo "**********************************"
echo "* Performing release..."
echo "**********************************"
mvn release:perform -Darguments="-DskipTests -Denv=hsqldb"
if [[ $? -ne 0 ]]; then
exit 1
fi
echo "**********************************"
echo "* Generating DB..."
echo "**********************************"
dirname=`pwd`
cd $dirname/target/checkout/sumaris-core
version=`grep -m1 -P "\<version>[0-9A−Z.]+(-\w*)?</version>" pom.xml | grep -oP "\d+.\d+.\d+(-\w*)?"`
# Generate the DB (run InitTest class)
mvn -Prun,hsqldb -DskipTests --quiet
if [[ $? -ne 0 ]]; then
exit 1
fi
# Create ZIP
cd target
zip -q -r "sumaris-db-$version.zip" db
if [[ $? -ne 0 ]]; then
exit 1
fi
echo "Generate DB [OK]"
echo "**********************************"
echo "* Pushing changes to upstream..."
echo "**********************************"
# Push git
cd $dirname
git push
if [[ $? -ne 0 ]]; then
exit
fi
# Pause (if propagation is need between hosted git server and github)
sleep 10s
echo "Push changes to upstream [OK]"
echo "**********************************"
echo "* Uploading artifacts to Github..."
echo "**********************************"
cd $dirname/target/checkout
./github.sh pre
if [[ $? -ne 0 ]]; then
exit 1
fi
echo "Upload artifacts to github [OK]"
echo "----------------------------------"
echo "RELEASE finished !"
echo "----------------------------------"
echo "Rebuild new SNAPSHOT version..."
mvn clean install -DskipTests --quiet
if [[ $? -ne 0 ]]; then
exit 1
fi
echo "Rebuild new SNAPSHOT version [OK]"