-
-
Notifications
You must be signed in to change notification settings - Fork 270
269 lines (235 loc) · 8.94 KB
/
build-release.yml
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
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
name: Build Release
on:
push:
tags: v[1-9]+.[0-9]+.*
jobs:
test:
runs-on: ubuntu-22.04
continue-on-error: ${{ matrix.experimental }}
strategy:
fail-fast: false
matrix:
php-version: ['8.2']
experimental: [false]
steps:
- uses: actions/checkout@v2
- name: Find the version
run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/v}" >> $GITHUB_ENV
- name: Show the discovered version
run: |
if [[ ! -z "${{ secrets.BUILD_TEST }}" ]]; then
echo "RELEASE_VERSION=build-testing-RC1" >> $GITHUB_ENV
fi
echo \$RELEASE_VERSION = $RELEASE_VERSION
echo \$\{\{ env.RELEASE_VERSION \}\} = ${{ env.RELEASE_VERSION }}
echo \$GITHUB_REF = $GITHUB_REF
- name: Set up PHP ${{ matrix.php-version }}
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-version }}
- name: Setup Packages
run: |
cd $GITHUB_WORKSPACE
sudo apt update && sudo apt install -y rsync
- name: Cache Composer dependencies
uses: actions/cache@v2
with:
path: /tmp/composer-cache
key: ${{ matrix.php-version }}-${{ env.RELEASE_VERSION }}-${{ hashFiles('**/composer.lock') }}
- name: Install dependencies
uses: php-actions/composer@v5
with:
dev: yes
args: --prefer-dist --no-interaction
php_version: ${{ matrix.php-version }}
php_extensions: xml
version: 2
- name: Install Plugins and Themes
run: |
cd $GITHUB_WORKSPACE
./scripts/install-plugins.sh vendor public_html/lists/admin/plugins/
./scripts/install-themes.sh vendor public_html/lists/admin/ui/
- name: Install the phpList4 based REST API
run: |
cd $GITHUB_WORKSPACE
cd public_html/lists
wget https://github.com/phpList/base-distribution/archive/refs/heads/phplist3.zip
unzip phplist3.zip
rm phplist3.zip
mv base-distribution-phplist3 base
cd base
composer update --no-dev
- name: Create Database
run: |
sudo systemctl start mysql.service
sudo mysql -proot -e 'drop database if exists phplistdb'
sudo mysqladmin -proot create phplistdb
sudo mysql -proot -e 'create user phplist@"%" identified by "phplist"; grant all on phplistdb.* to phplist@"%"'
- name: Start Test Server
run: |
cd $GITHUB_WORKSPACE
cp -fv tests/ci/behat.yml tests/behat.yml
cp -fv tests/ci/config.php public_html/lists/config/config.php
mkdir -p output/screenshots
mkdir -p build/mails
./bin/start-selenium > output/selenium.log 2>&1 &
sleep 5
sudo php -S 0.0.0.0:80 -t public_html > /dev/null 2>&1 &
- name: Check PHP syntax errors
uses: overtrue/[email protected]
with:
path: ./public_html
options: --exclude=base/vendor
- name: Report Versions
run: |
google-chrome --version
php -v
chromedriver -v
geckodriver -V
which geckodriver
which chromedriver
which rsync
rsync --version
firefox -v
which sftp
which sshpass
vendor/bin/behat -V
- name: Run Behat Tests
run: |
cd $GITHUB_WORKSPACE/tests
../vendor/bin/behat -n -fprogress -p chrome --strict --stop-on-failure --tags=@initialise
../vendor/bin/behat -n -fprogress -p chrome --strict --stop-on-failure --tags="~@initialise && ~@wip"
- name: Upload the screenshots
if: always()
uses: actions/upload-artifact@v2
with:
path: "output"
name: "behat output"
retention-days: 3
- name: Clean Up
run: |
cd $GITHUB_WORKSPACE
cd ..
mv phplist3 phplist-$RELEASE_VERSION
sudo find . -type d -exec chmod 755 {} \;
sudo find . -type f -exec chmod 644 {} \;
cd phplist-$RELEASE_VERSION
chmod 777 public_html/lists/admin/plugins
cat public_html/lists/admin/init.php | tr '\n' '\r' | sed 's~//## remove on rollout.*//## end remove on rollout ###~define("VERSION","'${RELEASE_VERSION}'");~' | tr '\r' '\n' > /tmp/$$.init
mv -f /tmp/$$.init public_html/lists/admin/init.php
sed -i s~define\(\'STRUCTUREVERSION\'.*~define\(\'STRUCTUREVERSION\',\"${RELEASE_VERSION}\"\)\;~ public_html/lists/admin/structure.php
sed -i s/^VERSION=.*/VERSION=${RELEASE_VERSION}/ VERSION
cd ..
zip -rq9 phplist-${RELEASE_VERSION}.zip phplist-${RELEASE_VERSION}
tar cf phplist-${RELEASE_VERSION}.tar phplist-${RELEASE_VERSION}
remove=(
default.behat.yml
TESTING.md
.dotgitlab-ci.yml
.travis.yml
composer.json
composer.lock
.git
.github
.php_cs
.gitmodules
Dockerfile
Vagrantfile
.styleci.yml
.gitignore
.gitsvnextmodules
tests
output.log
output
build
.phplist-cache
docker_tag
vendor
public_html/lists/admin/tests
scripts
bin/start-selenium
bin/fake-sendmail.sh
bin/imgur-uploader.sh
public_html/lists/base/tests
public_html/lists/base/.htaccess
public_html/lists/base/phpunit.xml.dist
public_html/lists/base/composer.lock
public_html/lists/base/CODE_OF_CONDUCT.md
public_html/lists/admin/ui/default
)
for item in ${remove[@]}; do
[[ -f phplist-$RELEASE_VERSION/$item ]] && {
tar -vf phplist-${RELEASE_VERSION}.tar --delete phplist-$RELEASE_VERSION/$item
zip -d phplist-${RELEASE_VERSION}.zip phplist-$RELEASE_VERSION/$item
}
[[ -d phplist-$RELEASE_VERSION/$item ]] && {
tar -vf phplist-${RELEASE_VERSION}.tar --delete phplist-$RELEASE_VERSION/$item
zip -d phplist-${RELEASE_VERSION}.zip phplist-$RELEASE_VERSION/$item/\*
}
done
gzip phplist-${RELEASE_VERSION}.tar
mv phplist-${RELEASE_VERSION}.tar.gz phplist-${RELEASE_VERSION}.tgz
md5sum phplist-${RELEASE_VERSION}.* > phplist-${RELEASE_VERSION}.md5
sha256sum phplist-${RELEASE_VERSION}.* > phplist-${RELEASE_VERSION}.sha256
sha1sum phplist-${RELEASE_VERSION}.* > phplist-${RELEASE_VERSION}.sha1
ls -l
## move the files for use in Docker build
mv phplist-$RELEASE_VERSION phplist3
cd $GITHUB_WORKSPACE
cp ../phplist-${RELEASE_VERSION}.tgz .
- name: Set up S3cmd cli tool
uses: s3-actions/[email protected]
with:
provider: aws
region: 'us-east-1'
access_key: ${{ secrets.AWS_KEY_ID }}
secret_key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
- name: Upload the files to S3
run: |
cd ..
s3cmd put phplist-${RELEASE_VERSION}.* s3://${{ secrets.AWS_S3_VERSIONS_BUCKET }}/
s3cmd put phplist3/public_html/lists/admin/images/power-phplist.png s3://${{ secrets.AWS_S3_POWERED_BUCKET }}/images/${RELEASE_VERSION}/
- name: Upload the package as artifact
if: always()
uses: actions/upload-artifact@v2
with:
path: "phplist-*.tgz"
name: "phpList Release File"
retention-days: 3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Login to DockerHub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and push
id: docker_build
uses: docker/build-push-action@v2
with:
context: .
push: true
no-cache: true
file: Dockerfile.release
tags: ${{ secrets.DOCKERHUB_REPO }}/${{ secrets.DOCKERHUB_IMAGE }}:${{ env.RELEASE_VERSION }}
build-args: |
VERSION=${{ env.RELEASE_VERSION }}
- name: Upload the files to SF
run: |
export SSHPASS=${{ secrets.SF_PASS }}
if [[ $RELEASE_VERSION =~ "-RC" ]]; then
RELEASE_FOLDER=phplist-development
else
RELEASE_FOLDER=phplist
fi
echo "${{ secrets.SF_HOSTKEY }}" >> ~/.ssh/known_hosts
cd $GITHUB_WORKSPACE
cd ..
sshpass -e sftp -oBatchMode=no -b - ${{ secrets.SF_USERNAME }}@${{ secrets.SF_HOST }} << EOF
cd /home/frs/project/phplist/$RELEASE_FOLDER
mkdir $RELEASE_VERSION
cd $RELEASE_VERSION
put phplist-${RELEASE_VERSION}.*
ls -l
bye
EOF