This repository has been archived by the owner on Aug 19, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathcreate-snapshot.sh
100 lines (85 loc) · 4.14 KB
/
create-snapshot.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
#!/bin/bash
# compiles the current LanguageTool code and moves the result to a snapshots directory
export JAVA_HOME=/home/languagetool/java
export MAVEN_OPTS="-Xmx1500M"
mailFromPart1=naber
mailFromPart2=danielnaber.de
mailToPart1=naber
mailToPart2=danielnaber.de
SNAPSHOT_DIR=../languagetool-website-2018/public/download/snapshots
if [ $# -eq 1 ]
then
BUILD_DATE=$1
else
BUILD_DATE=`date +%Y%m%d`
fi
STANDALONE_TARGET=$SNAPSHOT_DIR/LanguageTool-$BUILD_DATE-snapshot.zip
cd /home/languagetool/languagetool.org/git-checkout
git fetch && git rebase origin/master
# We need to build like this - building the top-level project and then taking the
# artifacts will aggregate *all* languages into the language-module.properties, even
# for those projects that don't depend on all of the languages:
mvn clean &&
mvn --projects languagetool-wikipedia --also-make package -DskipTests &&
mv languagetool-wikipedia/target/LanguageTool*.zip $SNAPSHOT_DIR/LanguageTool-wikipedia-`date +%Y%m%d`-snapshot.zip &&
mvn --projects languagetool-office-extension --also-make package -DskipTests &&
mv languagetool-office-extension/target/LanguageTool*.zip $SNAPSHOT_DIR/LanguageTool-`date +%Y%m%d`-snapshot.oxt &&
mvn --projects languagetool-standalone --also-make package -DskipTests &&
mv languagetool-standalone/target/LanguageTool*.zip $STANDALONE_TARGET
# delete files older than 10 days:
rm `find $SNAPSHOT_DIR -name "*.oxt" -mtime +10`
rm `find $SNAPSHOT_DIR -name "*.zip" -mtime +10`
# =====================================================================
# run tests:
# =====================================================================
export LANG=de_DE.UTF-8
cd /home/languagetool/languagetool.org/git-checkout
mvn -Dlt.default.port=8082 test
BUILD_SUCCESS=$?
if [ $BUILD_SUCCESS -ne 0 ]
then
echo "Tests failed, stopping deployment"
echo "See `uname -a` for details" | mail -aFrom:${mailFromPart1}@${mailFromPart2} -s "LanguageTool nightly build failed" ${mailToPart1}@${mailToPart2}
exit
fi
# =====================================================================
# deploy JARs to community.languagetool.org:
# =====================================================================
echo "--- Deploying JARs to community.languagetool.org ---"
/bin/sh /home/languagetool/languagetool.org/languagetool-website-2018/deploy-jars.sh
# =====================================================================
# deploy to API server:
# =====================================================================
echo "--- Deploying software snapshot to API server ---"
echo "--- Using ZIP: $STANDALONE_TARGET ---"
rm -r /home/languagetool/api/lt_bak
unzip -o -d /home/languagetool/api/lt_neu $STANDALONE_TARGET && \
mv /home/languagetool/api/lt_neu/LanguageTool-*-SNAPSHOT/* /home/languagetool/api/lt_neu && \
mv /home/languagetool/api/lt /home/languagetool/api/lt_bak && \
mv /home/languagetool/api/lt_neu /home/languagetool/api/lt && \
cd /home/languagetool/ && \
./restart-api-server.sh
# =====================================================================
# deploy community.languagetool.org web app:
# =====================================================================
echo "--- Deploying web app at community.languagetool.org ---"
cd /home/languagetool/languagetool.org/git-checkout
mvn install -DskipTests
# there's a Grails bug that causes Grails to not get new SNAPSHOT
# artifacts, so they need to be deleted manually:
rm -r ~/.grails/ivy-cache/org.languagetool/
cd /home/languagetool/languagetool.org/languagetool-community-website
# stash because e.g. Config.groovy is modified (locally it contains a password):
git stash
git pull -r
git stash pop
GRAILS_HOME=/home/languagetool/grails
PATH=$GRAILS_HOME/bin:$PATH
grails war
rm -r /home/languagetool/tomcat/webapps/ROOT/
unzip -o -d /home/languagetool/tomcat/webapps/ROOT/ target/ltcommunity-0.1.war
### Tomcat restart needs root permission, but that happens automatically by cron job
# since shortly after 4.1-SNAPSHOT there's a problem with dependencies (wrong slf4j-api
# version used) which we work around with this hack:
rm ~/tomcat/webapps/ROOT/WEB-INF/lib/slf4j-api-1.7.5.jar
cp ~/api/lt/libs/slf4j-api.jar ~/tomcat/webapps/ROOT/WEB-INF/lib/