-
-
Notifications
You must be signed in to change notification settings - Fork 7
221 lines (209 loc) · 8.05 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
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
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 }} on ${{ matrix.containers }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- php-versions: 5.3
containers: ubuntu:trusty
arch-suffix: ''
os: ubuntu-24.04
- php-versions: 5.4
containers: ubuntu:trusty
arch-suffix: ''
os: ubuntu-24.04
- php-versions: 5.5
containers: ubuntu:trusty
arch-suffix: ''
os: ubuntu-24.04
- php-versions: 5.3
containers: arm64v8/ubuntu:trusty
arch-suffix: '-arm64'
os: ubuntu-24.04-arm
- php-versions: 5.4
containers: arm64v8/ubuntu:trusty
arch-suffix: '-arm64'
os: ubuntu-24.04-arm
- php-versions: 5.5
containers: arm64v8/ubuntu:trusty
arch-suffix: '-arm64'
os: ubuntu-24.04-arm
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Cache Docker layers
uses: actions/cache@v4
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-docker-php-${{ matrix.php-versions }}${{ matrix.arch-suffix }}-${{ matrix.os }}-${{ github.run_id }}-${{ github.run_number }}
restore-keys: ${{ runner.os }}-docker-php-${{ matrix.php-versions }}${{ matrix.arch-suffix }}-${{ matrix.os }}
- name: Build
uses: docker/build-push-action@v6
with:
context: .
tags: php-${{ matrix.php-versions }}${{ matrix.arch-suffix }}
build-args: |
PHP_VERSION=${{ matrix.php-versions }}
UBUNTU_VERSION=${{ matrix.containers }}
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 }}${{ matrix.arch-suffix }}.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${{ matrix.arch-suffix }}.tar
docker run --name=php-$PHP_VERSION${{ matrix.arch-suffix }} php-$PHP_VERSION${{ matrix.arch-suffix }} sh -c exit
sudo chmod 777 /usr/local
docker cp php-$PHP_VERSION${{ matrix.arch-suffix }}:/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@v4
with:
name: php${{ matrix.php-versions }}${{ matrix.arch-suffix }}
path: ${{ github.workspace }}/php-${{ matrix.php-versions }}-build${{ matrix.arch-suffix }}.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:
php-versions: [5.3, 5.4, 5.5]
operating-system: [ubuntu-24.04, ubuntu-22.04, ubuntu-20.04, ubuntu-22.04-arm, ubuntu-24.04-arm]
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Stage PHP
run: |
bash scripts/version-files.sh ${{ matrix.php-versions }}
bash scripts/stage.sh ${{ matrix.php-versions }}
arch="$(arch)"
[[ "$arch" = "arm64" || "$arch" = "aarch64" ]] && arch_suffix="-arm64" || arch_suffix=""
gh release download -p "php-${{ matrix.php-versions }}-build$arch_suffix.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: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
php-versions: ['5.3', '5.4', '5.5']
os: [ubuntu-24.04, ubuntu-24.04-arm]
steps:
- name: Checkout
uses: actions/checkout@v4
- 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"
arch="$(arch)"
[[ "$arch" = "arm64" || "$arch" = "aarch64" ]] && arch_suffix="-arm64" || arch_suffix=""
gh release download -p php-"$PHP_VERSION"-build"$arch_suffix".tar.zst -D php-"$PHP_VERSION"
sudo XZ_OPT=-e9 tar cfJ php-"$PHP_VERSION$arch_suffix".tar.xz php-"$PHP_VERSION"
sudo tar cf - php-"$PHP_VERSION" | zstd -22 -T0 --ultra > php-"$PHP_VERSION$arch_suffix".tar.zst
mv php-"$PHP_VERSION$arch_suffix".tar.* ./builds/
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PHP_VERSION: ${{ matrix.php-versions }}
- name: Upload Artifact
uses: actions/upload-artifact@v4
with:
name: builds-${{ matrix.php-versions }}-${{ matrix.os }}
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@v4
- run: mkdir builds
- uses: actions/download-artifact@v4
with:
pattern: builds-*
path: builds
merge-multiple: true
- 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 }}