-
Notifications
You must be signed in to change notification settings - Fork 146
/
deploy.sh
executable file
·243 lines (212 loc) · 6.72 KB
/
deploy.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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
#!/usr/bin/env bash
SEVNTU_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
GH_SEVNTU_DIR="/tmp/sevntu.checkstyle.gh"
PROJECT_NAME="sevntu.checkstyle"
GH_SEVNTU_HOMR_DIR="$GH_SEVNTU_DIR/$PROJECT_NAME"
GITHUB_PROJECT="sevntu-checkstyle/$PROJECT_NAME"
usage="$(basename "$0") [--help --all --eclipse-cs --sonar --idea]
where:
--help show this help text
--all deploy all projects;
--eclipse-cs deploy only 'sevntu-checkstyle-eclipsecs-plugin' project;
--sonar deploy only 'sevntu-checkstyle-sonar-plugin' project;
--idea deploy only 'sevntu-checkstyle-idea-extension' project;
--maven-central deploy to maven central;
--gh-pages deploy only gh-pages binaries with version argument;
"
manualDeploy="
For new version deploy please do:
cd gh-pages && git add . && git commit -m \"new version deploy\" && git push origin gh-pages
"
prepareForDeploy()
{
echo "Preparing for Deployment"
if [ ! -d $GH_SEVNTU_DIR ]; then
mkdir $GH_SEVNTU_DIR
fi
cd $GH_SEVNTU_DIR
if [ ! -d "$GH_SEVNTU_DIR/$PROJECT_NAME/.git" ]; then
git clone https://github.com/$GITHUB_PROJECT.git
cd $GH_SEVNTU_HOMR_DIR
else
cd $GH_SEVNTU_HOMR_DIR
git fetch origin
fi
git reset --hard HEAD
git clean -f -d
git checkout origin/gh-pages
return
}
deployIdea()
{
echo "Deploying Idea"
cd $SEVNTU_DIR/sevntu-checkstyle-idea-extension/
mvn -e --no-transfer-progress clean javadoc:javadoc deploy -Plocal-deploy \
-DdeployDir=$GH_SEVNTU_HOMR_DIR
if [ "$?" != "0" ]
then
echo "build for $SEVNTU_DIR/sevntu-checkstyle-idea-extension/"
exit 1
fi
cd $GH_SEVNTU_HOMR_DIR
echo "$manualDeploy"
return
}
deployEclipse()
{
echo "Deploying Eclipse"
cd $SEVNTU_DIR
#echo -n "Enter version number: "
#read version
#mvn org.eclipse.tycho:tycho-versions-plugin:set-version -DnewVersion=$version \
#-f eclipse-pom.xml
mvn -e --no-transfer-progress clean install -f eclipse-pom.xml -Plocal-deploy
if [ "$?" != "0" ]
then
echo "build for eclipse-pom.xml."
exit 1
fi
cd $SEVNTU_DIR/update-site
mvn -e --no-transfer-progress wagon:upload -DdeployDir=$GH_SEVNTU_HOMR_DIR
cd $GH_SEVNTU_HOMR_DIR
echo "$manualDeploy"
return
}
deployMavenLibrary()
{
echo "Deploying Sevntu Checks"
# As we do not use SNAPSHOT qualifier for development in pom.xml
# we have to deploy library sevntu-checks always even it overrides existing binaries
# in maven repository for release build - it will not override binaries
# for test build - it will override as we need to be sure that in repository,
# we have previous release version but compiled with from new code
cd $SEVNTU_DIR/sevntu-checks
mvn -e --no-transfer-progress clean javadoc:javadoc deploy -Plocal-deploy \
-DdeployDir=$GH_SEVNTU_HOMR_DIR
if [ "$?" != "0" ]
then
echo "build for $SEVNTU_DIR/sevntu-checks."
exit 1
fi
# deployment of Javadoc to static site
cp -rf target/site/apidocs $GH_SEVNTU_HOMR_DIR
# no need push to repository only library it should be done together with IDE plugins
# release
#cd $GH_SEVNTU_HOMR_DIR
#echo "$manualDeploy"
return
}
deployToMavenCentral()
{
echo "Deploying All to Maven Central"
# As we do not use SNAPSHOT qualifier for development in pom.xml
# we have to deploy library sevntu-checks always even it overrides existing binaries
# in maven repository for release build - it will not override binaries
# for test build - it will override as we need to be sure that in repository,
# we have previous release version but compiled with from new code
cd $SEVNTU_DIR/sevntu-checks
mvn -e --no-transfer-progress clean deploy -DskipStaging=false -Pgpg
if [ "$?" != "0" ]
then
echo "build for $SEVNTU_DIR/sevntu-checks."
exit 1
fi
cd $SEVNTU_DIR/sevntu-checkstyle-idea-extension/
mvn -e --no-transfer-progress clean deploy -DskipStaging=false -Pgpg
cd $SEVNTU_DIR/sevntu-checkstyle-sonar-plugin/
mvn -e --no-transfer-progress clean deploy -DskipStaging=false -Pgpg
return
}
deploySonar()
{
echo "Deploying Sonar"
cd $SEVNTU_DIR/sevntu-checkstyle-sonar-plugin/
mvn -e --no-transfer-progress clean install wagon:upload-single \
-DdeployDir=$GH_SEVNTU_HOMR_DIR
if [ "$?" != "0" ]
then
echo "build for $SEVNTU_DIR/sevntu-checkstyle-sonar-plugin/"
exit 1
fi
cd $GH_SEVNTU_HOMR_DIR
echo "$manualDeploy"
return
}
deployToGhPages()
{
echo "Deploying GH Pages"
cd $GH_SEVNTU_HOMR_DIR
sed -i "/<h2> New and noteworthy<\/h2>/ r $2" index.html
git add .
git commit -m "binaries for $1 release"
CURRENT_COMMIT=$(git rev-parse HEAD)
git push origin $CURRENT_COMMIT:gh-pages
return
}
if [ $# -eq 0 ]
then
echo "$usage"
fi
while :
do
case $1 in
--help | -\?)
echo "$usage"
exit 0
;;
--all)
prepareForDeploy
deployMavenLibrary
deployEclipse
deployIdea
deploySonar
echo "$manualDeploy"
shift 1
;;
--eclipse-cs)
prepareForDeploy
deployMavenLibrary
deployEclipse
shift 1
;;
--sonar)
prepareForDeploy
deployMavenLibrary
deploySonar
shift 1
;;
--idea)
prepareForDeploy
deployMavenLibrary
deployIdea
shift 1
;;
--gh-pages)
if [ $# -eq 0 ]
then
echo "$usage"
shift 1
else
deployToGhPages $2 $3
shift 3
fi
;;
--maven-central)
deployToMavenCentral
shift 1
;;
--) # End of all options
shift
break
;;
-*)
echo "WARN: Unknown option : $1"
echo "$usage"
shift
exit 0
;;
*) # no more options. Stop while loop
break
;;
esac
done