-
-
Notifications
You must be signed in to change notification settings - Fork 7
189 lines (177 loc) · 6.46 KB
/
ci.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
name: Test
on:
workflow_dispatch:
push:
jobs:
build-php:
if: "!contains(github.event.head_commit.message, 'skip-build-php')"
name: Build PHP ${{ matrix.php-versions }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
php-versions: [5.3, 5.4, 5.5]
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Cache Docker layers
uses: actions/cache@v2
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-docker-php-${{ matrix.php-versions }}-${{ github.run_id }}-${{ github.run_number }}
restore-keys: ${{ runner.os }}-docker-php-${{ matrix.php-versions }}
- name: Build
uses: docker/build-push-action@v2
with:
context: .
tags: php-${{ matrix.php-versions }}
build-args: PHP_VERSION=${{ matrix.php-versions }}
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache-new
outputs: type=docker,dest=/tmp/php-${{ matrix.php-versions }}.tar
# https://github.com/docker/build-push-action/issues/252
- name: Move build cache
run: |
rm -rf /tmp/.buildx-cache
mv /tmp/.buildx-cache-new /tmp/.buildx-cache
- name: Copy build
env:
PHP_VERSION: ${{ matrix.php-versions }}
run: |
docker load --input /tmp/php-$PHP_VERSION.tar
docker run --name=php-$PHP_VERSION php-$PHP_VERSION sh -c exit
sudo chmod 777 /usr/local
docker cp php-$PHP_VERSION:/usr/local/php /usr/local/php
- name: Package and ship artifact to releases
run: bash scripts/build.sh ship
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITHUB_WORKSPACE: ${{ github.workspace }}
PHP_VERSION: ${{ matrix.php-versions }}
REPO: ${{ github.repository }}
USER: ${{ github.repository_owner }}
- name: Upload artifact to workflow
uses: actions/upload-artifact@v2
with:
name: php${{ matrix.php-versions }}
path: ${{ github.workspace }}/php-${{ matrix.php-versions }}-build.tar.zst
test:
needs: build-php
if: ${{ always() }}
name: Test PHP-${{ matrix.php-versions }} on ${{ matrix.operating-system }}
runs-on: ${{ matrix.operating-system }}
strategy:
fail-fast: false
matrix:
operating-system: [ubuntu-24.04, ubuntu-22.04, ubuntu-20.04]
php-versions: ['5.3', '5.4', '5.5']
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Stage PHP
run: |
bash scripts/version-files.sh ${{ matrix.php-versions }}
bash scripts/stage.sh ${{ matrix.php-versions }}
gh release download -p 'php-${{ matrix.php-versions }}-build.tar.zst' -D php-${{ matrix.php-versions }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Install PHP
run: |
cd php-${{ matrix.php-versions }} || exit
sudo chmod a+x *.sh
./install-php.sh
./post-install.sh
- name: Test libs
run: sudo apt-get -f install
- name: Test versions and extensions
run: |
php$ver -v | head -n 1
php-config$ver --version
phpize$ver -v
php$ver -m
php-cgi -v
php-fpm -v
pecl -V
curl -V
sudo service php$ver-fpm status
php$ver -r "echo file_get_contents('https://repo.packagist.org/packages.json');"
env:
ver: ${{ matrix.php-versions }}
- name: Test SAPI
run: |
sudo rm -rf /var/www/html/index.html
echo "<?php echo current(explode('-', php_sapi_name())).':'.strtolower(current(explode('/', \$_SERVER['SERVER_SOFTWARE']))).\"\n\";" | sudo tee /var/www/html/index.php >/dev/null
for sapi in apache2handler:apache fpm:apache cgi:apache fpm:nginx; do
echo "::group::Test $sapi"
sudo switch_sapi $sapi >/dev/null
curl -s http://localhost
[ "$(curl -s http://localhost)" != "$sapi" ] && exit 1
echo "::endgroup::"
done
package:
name: Update dist
if: "!contains(github.event.head_commit.message, 'skip-release')"
needs: [build-php, test]
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
php-versions: ['5.3', '5.4', '5.5']
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Add ZSTD
env:
REPO: ${{ github.repository }}
TOKEN: ${{ secrets.GITHUB_TOKEN }}
USER: ${{ github.repository_owner }}
run: bash scripts/install-zstd.sh
- name: Package
run: |
mkdir builds
bash scripts/version-files.sh "$PHP_VERSION"
bash scripts/stage.sh "$PHP_VERSION"
gh release download -p php-"$PHP_VERSION"-build.tar.zst -D php-"$PHP_VERSION"
sudo XZ_OPT=-e9 tar cfJ php-"$PHP_VERSION".tar.xz php-"$PHP_VERSION"
sudo tar cf - php-"$PHP_VERSION" | zstd -22 -T0 --ultra > php-"$PHP_VERSION".tar.zst
mv php-"$PHP_VERSION".tar.* ./builds/
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PHP_VERSION: ${{ matrix.php-versions }}
- name: Upload Artifact
uses: actions/upload-artifact@v2
with:
name: builds
path: builds
release:
runs-on: ubuntu-latest
if: "!contains(github.event.head_commit.message, 'skip-release')"
needs: [build-php, test, package]
steps:
- uses: actions/checkout@v3
- run: mkdir builds
- uses: actions/download-artifact@v2
with:
name: builds
path: builds
- name: Release
run: |
set -x
assets=()
for asset in ./builds/*; do
assets+=("$asset")
done
assets+=("./scripts/install.sh")
gh release download -p "release.log" || true
echo "$(date "+%Y-%m-%d %H:%M:%S") Update ${assets[@]}" | sudo tee -a release.log >/dev/null 2>&1
assets+=("./release.log")
exists=$(gh release list | grep -Po 'builds' | head -n 1)
if [ "x$exists" != "xbuilds" ]; then
gh release create "builds" "${assets[@]}" -n "builds" -t "builds"
else
gh release upload "builds" "${assets[@]}" --clobber
fi
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}