-
-
Notifications
You must be signed in to change notification settings - Fork 4
191 lines (169 loc) · 6.06 KB
/
cache-stable.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
name: Cache PHP for stable versions
on:
push:
workflow_dispatch:
inputs:
php-versions:
description: 'PHP version to build'
default: '5.6 7.0 7.1 7.2 7.3 7.4 8.0 8.1 8.2 8.3'
required: false
builds:
description: 'Build type'
default: 'debug release'
required: false
ts:
description: 'Type safety'
default: 'nts zts'
required: false
containers:
description: 'OS containers'
default: '24.04 22.04 20.04'
required: false
env:
PHP_VERSIONS: '5.6 7.0 7.1 7.2 7.3 7.4 8.0 8.1 8.2 8.3'
BUILDS: 'debug release'
TS: 'nts zts'
CONTAINERS: '24.04 22.04 20.04'
jobs:
get-matrix:
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.get-matrix.outputs.matrix }}
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Get Matrix
id: get-matrix
run: bash scripts/get-matrix.sh
env:
PHP_VERSIONS: ${{ inputs.php-versions || env.PHP_VERSIONS }}
BUILDS: ${{ inputs.builds || env.BUILDS }}
TS: ${{ inputs.ts || env.TS }}
CONTAINERS: ${{ inputs.containers || env.CONTAINERS }}
cache:
needs: get-matrix
container: ubuntu:${{ matrix.container }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix: ${{fromJson(needs.get-matrix.outputs.matrix)}}
if: "!contains(github.event.head_commit.message, 'skip-cache')"
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Install requirements
run: bash scripts/install-requirements.sh
env:
PHP_VERSION: ${{ matrix.php-versions }}
BUILDS: ${{ matrix.builds }}
NIGHTLY: 'false'
TS: ${{ matrix.ts }}
- name: Get ZSTD_DIR
id: zstd
run: echo "ZSTD_DIR=zstd-$(curl -sL https://github.com/facebook/zstd/releases/latest | grep -Po "tree/v(\d+\.\d+\.\d+)" | cut -d'v' -f 2 | head -n 1)" | tee -a "$GITHUB_OUTPUT"
- name: Add ZSTD
env:
CONTAINER: ${{ matrix.container }}
REPO: ${{ github.repository }}
TOKEN: ${{ secrets.GITHUB_TOKEN }}
USER: ${{ github.repository_owner }}
ZSTD_DIR: ${{ steps.zstd.outputs.ZSTD_DIR }}
run: bash scripts/install-zstd.sh
- name: Configure git
run: bash scripts/configure-git.sh
- name: Setup PHP
env:
PHP_VERSION: ${{ matrix.php-versions }}
BUILDS: ${{ matrix.builds }}
NIGHTLY: 'false'
TS: ${{ matrix.ts }}
run: bash scripts/install-php.sh
- name: Build package
env:
GITHUB_WORKSPACE: ${{ github.workspace }}
PHP_VERSION: ${{ matrix.php-versions }}
BUILDS: ${{ matrix.builds }}
TS: ${{ matrix.ts }}
run: bash scripts/package-php.sh
- name: Upload zstd Artifact
if: matrix.php-versions == '8.0'
uses: actions/upload-artifact@v3
with:
name: ${{ steps.zstd.outputs.zstd_dir }}-ubuntu${{ matrix.container }}
path: /opt/zstd
- name: Upload Artifact
uses: actions/upload-artifact@v3
with:
name: ${{ matrix.php-versions }}
path: builds
tests:
runs-on: ${{ matrix.os }}
needs: [get-matrix, cache]
strategy:
fail-fast: false
matrix: ${{fromJson(needs.get-matrix.outputs.matrix)}}
if: "!contains(github.event.head_commit.message, 'skip-tests')"
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Download Artifact
uses: actions/download-artifact@v3
with:
name: ${{ matrix.php-versions }}
path: /tmp
- name: Patch script
run: sed -i -e '/releases/d' -e '$s/fix_packages//' -e '1s/$/\n\nset -x/' scripts/install.sh
- name: Setup PHP
run: bash scripts/install.sh ${{ matrix.php-versions }} ${{ matrix.builds }} ${{ matrix.ts }}
- name: Switch versions
run: |
sudo update-alternatives --set php-cgi-bin /usr/lib/cgi-bin/php${{ matrix.php-versions }}
sudo update-alternatives --set php-fpm /usr/sbin/php-fpm${{ matrix.php-versions }}
sudo update-alternatives --set php-fpm.sock /run/php/php${{ matrix.php-versions }}-fpm.sock
for tool in phpize php-config phpdbg php-cgi php phar.phar phar; do
sudo update-alternatives --set "$tool" /usr/bin/"$tool"${{ matrix.php-versions }}
done
- name: Test PHP
run: |
file /usr/bin/php${{ matrix.php-versions }}
php -v
php-config --version
php-fpm -v
php-cgi -v
phpize -v
php -m
sudo service php${{ matrix.php-versions }}-fpm status || exit 1
php -v | grep -q '${{ matrix.php-versions }}' || exit 1
php-config --version | grep -q '${{ matrix.php-versions }}' || exit 1
phpize -v | grep -q "$(php-config --phpapi)" || exit 1
php-fpm -v | grep -q '${{ matrix.php-versions }}' || exit 1
php-cgi -v | grep -q '${{ matrix.php-versions }}' || exit 1
- name: Test broken packages
run: sudo apt-get check
release:
runs-on: ubuntu-latest
needs: [get-matrix, cache, tests]
if: "!contains(github.event.head_commit.message, 'skip-release')"
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Create builds directory
run: mkdir builds
- name: Download artifacts
uses: actions/download-artifact@v3
with:
path: builds
- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: 3.x
- name: Install cloudsmith-cli
run: pip install --upgrade cloudsmith-cli
- name: Release
run: bash scripts/release.sh
env:
CLOUDSMITH_API_KEY: ${{ secrets.CLOUDSMITH_API_KEY }}
GITHUB_MESSAGE: ${{ github.event.head_commit.message }}
GITHUB_REPOSITORY: ${{ github.repository }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITHUB_WORKSPACE: ${{ github.workspace }}