-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.xml
115 lines (103 loc) · 3.42 KB
/
build.xml
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
<?xml version="1.0" encoding="utf-8"?>
<project basedir="." name="Ylias" default="deploy">
<property file="database.properties"/>
<property file="discord.properties"/>
<property file="build.properties"/>
<property name="ProdToken" value="${OAuthProdToken}"/>
<target name="deploy">
<antcall target="set-token"/>
<antcall target="package"/>
<antcall target="upload"/>
<antcall target="remove-package"/>
<antcall target="unpack"/>
<antcall target="delete-package"/>
<antcall target="unset-token"/>
<antcall target="dump-sql"/>
</target>
<target name="dump-sql">
<exec executable="mysqldump" output="database.sql">
<arg value="-d" />
<arg value="--user=${dbUser}" />
<arg value="--password=${dbPassword}" />
<arg value="--host=${dbHost}" />
<arg value="--port=${dbPort}" />
<arg value="${dbName}" />
</exec>
<loadfile srcfile="database.sql" property="validDump">
<filterchain>
<filterreader classname="org.apache.tools.ant.filters.HeadFilter">
<param name="lines" value="-1"/>
<param name="skip" value="7"/>
</filterreader>
<filterreader classname="org.apache.tools.ant.filters.TailFilter">
<param name="lines" value="-1"/>
<param name="skip" value="2"/>
</filterreader>
</filterchain>
</loadfile>
<echo message="${validDump}" file="database.sql" />
<replaceregexp
file="database.sql"
match=" AUTO_INCREMENT=\d+"
replace=""
flags="g"
/>
</target>
<target name="set-token">
<replace
file="out/bot.js"
token="${DebugToken}"
value="${ProdToken}"
/>
</target>
<target name="package">
<tar destfile="${archiveFilename}" compression="gzip">
<tarfileset dir="${basedir}/out" filemode="775" dirmode="775">
<include name="bot.js"/>
<include name="package.json"/>
</tarfileset>
</tar>
</target>
<target name="upload">
<scp
file="${archiveFilename}"
todir="${sshUser}@${sshHost}:${sshFolder}"
keyfile="${sshKeyFile}"
verbose="false" sftp="true"
trust="true"
dirmode="775"
filemode="775"
/>
</target>
<target name="remove-package">
<echo>remove package...</echo>
<delete file="site.tar.gz"/>
</target>
<target name="unpack">
<sshexec
host="${sshHost}"
username="${sshUser}"
keyfile="${sshKeyFile}"
verbose="false"
trust="true"
command="tar -zxf ${sshFolder}/${archiveFilename} -C ${sshFolder}/"
/>
</target>
<target name="delete-package">
<sshexec
host="${sshHost}"
username="${sshUser}"
keyfile="${sshKeyFile}"
verbose="false"
trust="true"
command="rm ${sshFolder}/${archiveFilename}"
/>
</target>
<target name="unset-token">
<replace
file="out/bot.js"
token="${ProdToken}"
value="${DebugToken}"
/>
</target>
</project>