|
1 | 1 | <?xml version="1.0" encoding="UTF-8" ?> |
2 | 2 | <project name="SRS" basedir="." default="main"> |
3 | 3 | <property name="tempDir" value="temp"/> |
| 4 | + |
4 | 5 | <target name="main" description="Runs tests and prepares deployable tarball"> |
5 | 6 | <exec executable="composer" passthru="true"> |
6 | 7 | <arg value="install"/> |
|
20 | 21 |
|
21 | 22 | <target name="prepare-tarball" description="Prepares deployable tarball with everything built"> |
22 | 23 | <exec executable="git" outputProperty="build.hash"> |
23 | | - <arg value="rev-parse"/> |
24 | | - <arg value="--short HEAD"/> |
| 24 | + <arg line="rev-parse --short HEAD"/> |
25 | 25 | </exec> |
26 | 26 |
|
27 | 27 | <property name="build.dir" value="${tempDir}/builds/${build.hash}"/> |
|
104 | 104 | </fileset> |
105 | 105 | </tar> |
106 | 106 |
|
107 | | - <delete dir="${build.dir}" /> |
| 107 | + <delete dir="${build.dir}"/> |
108 | 108 | </target> |
109 | 109 |
|
110 | 110 | <target name="deploy:ssh"> |
111 | 111 | <echo message="${comment}..."/> |
112 | 112 | <echo message="${command}"/> |
113 | | - <exec executable="ssh" passthru="true" checkreturn="true"> |
114 | | - <arg value="${deploy.ssh.target}"/> |
115 | | - <arg value="-p ${deploy.ssh.port}"/> |
116 | | - <arg value="'${command}'"/> |
117 | | - </exec> |
| 113 | + <ssh host="${deploy.ssh.host}" port="${deploy.ssh.port}" username="${deploy.ssh.username}" privkeyfile="id_rsa" |
| 114 | + pubkeyfile="id_rsa.pub" command="${command}"/> |
118 | 115 | </target> |
119 | 116 |
|
120 | 117 | <target name="deploy:copy-tarball"> |
121 | | - <property name="command" value="scp"/> |
122 | | - <property name="args" value="-P ${port} ${file} '${target}:${toDirectory}'"/> |
123 | | - <echo message="Copying files to ${deploy.ssh.target}"/> |
124 | | - <echo message="${command} ${args}"/> |
125 | | - <exec executable="${command}" passthru="true" checkreturn="true"> |
126 | | - <arg value="${args}"/> |
127 | | - </exec> |
| 118 | + <echo message="Copying ${file} to ${toDirectory}"/> |
| 119 | + <scp host="${deploy.ssh.host}" port="${deploy.ssh.port}" username="${deploy.ssh.username}" privkeyfile="id_rsa" |
| 120 | + pubkeyfile="id_rsa.pub" file="${file}" todir="${toDirectory}"/> |
128 | 121 | </target> |
129 | 122 |
|
130 | 123 | <target name="deploy:cleanup"> |
131 | | - <echo message="Getting previous releases"/> |
| 124 | + <ssh host="${deploy.ssh.host}" port="${deploy.ssh.port}" username="${deploy.ssh.username}" privkeyfile="id_rsa" |
| 125 | + pubkeyfile="id_rsa.pub" command="ls ${deploy.releasesDir}" property="allReleases"/> |
132 | 126 |
|
133 | | - <property name="command" value="echo $(ssh -p ${deploy.ssh.port} ${deploy.ssh.target} 'ls ${deploy.releasesDir}' | grep -v '^${deploy.releaseHash}$')"/> |
134 | | - <echo message="${command}"/> |
135 | | - <exec outputProperty="previousReleases" command="${command}" checkreturn="true"/> |
| 127 | + <exec executable="bash" outputProperty="previousReleases" checkreturn="true"> |
| 128 | + <arg value="-c"/> |
| 129 | + <arg line='"echo '${allReleases}' | grep -v '^${deploy.releaseHash}$' | tr '\n' ' '"'/> |
| 130 | + </exec> |
136 | 131 |
|
137 | 132 | <phingcall target="deploy:ssh"> |
138 | 133 | <property name="comment" value="Deleting files"/> |
|
146 | 141 | <!-- Prepare variables --> |
147 | 142 | <property environment="env"/> |
148 | 143 | <property name="deploy.workDir" refid="env.DEPLOY_DIRECTORY"/> |
149 | | - <property name="deploy.releasesDir" value="${deploy.workDir}/releases"/> |
150 | | - <exec executable="git" outputProperty="build.hash"> |
151 | | - <arg value="rev-parse"/> |
152 | | - <arg value="--short HEAD"/> |
153 | | - </exec> |
154 | 144 | <property name="deploy.lebeda" refid="env.DEPLOY_LEBEDA"/> |
155 | 145 | <property name="deploy.ssh.host" refid="env.DEPLOY_SSH_HOST"/> |
156 | | - <property name="deploy.ssh.username" refid="env.DEPLOY_SSH_USERNAME"/> |
157 | 146 | <property name="deploy.ssh.port" refid="env.DEPLOY_SSH_PORT"/> |
158 | | - <property name="deploy.ssh.target" value="${deploy.ssh.username}@${deploy.ssh.host}"/> |
| 147 | + <property name="deploy.ssh.username" refid="env.DEPLOY_SSH_USERNAME"/> |
| 148 | + |
| 149 | + <exec executable="git" outputProperty="build.hash"> |
| 150 | + <arg line="rev-parse --short HEAD"/> |
| 151 | + </exec> |
| 152 | + <property name="deploy.releasesDir" value="${deploy.workDir}/releases"/> |
159 | 153 | <property name="deploy.releaseHash" value="${DSTAMP}-${TSTAMP}-${build.hash}"/> |
160 | 154 | <property name="deploy.release" value="${deploy.releasesDir}/${deploy.releaseHash}"/> |
| 155 | + <property name="tarball" value="${deploy.release}.tar.gz"/> |
161 | 156 |
|
162 | 157 | <!-- Build tarball --> |
163 | 158 | <phingcall target="prepare-tarball"> |
|
170 | 165 | </phingcall> |
171 | 166 |
|
172 | 167 | <phingcall target="deploy:copy-tarball"> |
173 | | - <property name="target" value="${deploy.ssh.target}"/> |
174 | | - <property name="port" value="${deploy.ssh.port}"/> |
175 | 168 | <property name="file" value="${tempDir}/builds/${deploy.releaseHash}.tar.gz"/> |
176 | 169 | <property name="toDirectory" value="${deploy.releasesDir}"/> |
177 | 170 | </phingcall> |
178 | 171 |
|
179 | | - <property name="tarball" value="${deploy.release}.tar.gz"/> |
180 | | - |
181 | 172 | <phingcall target="deploy:ssh"> |
182 | 173 | <property name="comment" value="Extracting tarball to release directory"/> |
183 | 174 | <property name="command" value="tar -xzf ${tarball} -C ${deploy.releasesDir}"/> |
|
190 | 181 |
|
191 | 182 | <phingcall target="deploy:ssh"> |
192 | 183 | <property name="comment" value="Copying custom CSS"/> |
193 | | - <property name="command" value="cp ${deploy.workDir}/www/css/web/style.css ${deploy.release}/www/css/web || true"/> |
| 184 | + <property name="command" |
| 185 | + value="cp ${deploy.workDir}/www/css/web/style.css ${deploy.release}/www/css/web || true"/> |
194 | 186 | </phingcall> |
195 | 187 |
|
196 | 188 | <phingcall target="deploy:ssh"> |
|
255 | 247 |
|
256 | 248 | <phingcall target="deploy:ssh"> |
257 | 249 | <property name="comment" value="Swapping release to ${deploy.releaseHash}"/> |
258 | | - <property name="command" value="rm -rf ${deploy.workDir}/www && ln -s ${deploy.release}/www ${deploy.workDir}/www"/> |
| 250 | + <property name="command" |
| 251 | + value="rm -rf ${deploy.workDir}/www && ln -s ${deploy.release}/www ${deploy.workDir}/www"/> |
259 | 252 | </phingcall> |
260 | 253 |
|
261 | 254 | <phingcall target="deploy:cleanup"/> |
262 | 255 | </target> |
263 | 256 |
|
264 | 257 | <target name="deploy:app-command"> |
265 | 258 | <condition property="phpCommand" |
266 | | - value="php81-cli "${deploy.release}/www/console.php ${command}"" |
267 | | - else="php8.1 ${deploy.release}/www/console.php ${command}"> |
| 259 | + value="php83-cli "${deploy.release}/www/console.php ${command}"" |
| 260 | + else="php8.3 ${deploy.release}/www/console.php ${command}"> |
268 | 261 | <equals arg1="${deploy.lebeda}" arg2="true"/> |
269 | 262 | </condition> |
270 | 263 | <phingcall target="deploy:ssh"> |
|
310 | 303 | </target> |
311 | 304 |
|
312 | 305 | <target name="static-analysis"> |
313 | | - <exec executable="php" passthru="true" checkreturn="true"> |
314 | | - <arg value="-d memory_limit=1024M"/> |
315 | | - <arg value="vendor/bin/phpstan"/> |
316 | | - <arg value="analyse"/> |
317 | | - <arg value="-l6"/> |
318 | | - <arg value="-cphpstan.neon"/> |
319 | | - <arg value="app"/> |
320 | | - <arg value="--no-progress"/> |
321 | | - </exec> |
| 306 | + <phpstan executable="vendor/bin/phpstan" command="analyse" passthru="true" checkReturn="true" paths="app" |
| 307 | + configuration="phpstan.neon" level="6" noProgress="true" memoryLimit="1024M"/> |
322 | 308 | </target> |
323 | 309 |
|
324 | 310 | <target name="coding-standard"> |
|
0 commit comments