-
Notifications
You must be signed in to change notification settings - Fork 0
247 lines (215 loc) · 7.92 KB
/
release.yml
File metadata and controls
247 lines (215 loc) · 7.92 KB
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
name: Release
# https://github.com/shivammathur/setup-php
on:
push:
branches: [ rc** ]
pull_request:
branches-ignore: [ master ]
jobs:
build_rc:
name: Build php ${{ matrix.php-versions }} version
runs-on: ${{ matrix.operating-system }}
strategy:
fail-fast: false
matrix:
operating-system: [ubuntu-latest]
php-versions: ['7.4', '8.1']
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-versions }}
coverage: none
- name: Get composer cache directory
id: composer-cache
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
- name: Cache dependencies
uses: actions/cache@v4
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-rc-${{ matrix.php-versions }}-${{ hashFiles('**/composer.json') }}
restore-keys: |
${{ runner.os }}-
- name: Install dependencies
env:
# setup-php@v2 writes ~/.composer/auth.json with $GITHUB_TOKEN by
# default. Recently that token has been occasionally malformed
# (newlines embedded), causing composer to fail with "github oauth
# token contains invalid characters". Our deps are all public, so
# we drop the auto-written auth before install.
COMPOSER_AUTH: '{}'
run: |
rm -f ~/.composer/auth.json ~/.config/composer/auth.json
chmod -R +x tools/*
tools/composer install --prefer-dist --no-progress
- name: Build the Aplication
run: |
php --version
php githooks app:pre-build php
php githooks app:build
git status --short
- name: Upload build artifact
uses: actions/upload-artifact@v4
with:
name: githooks-${{ matrix.php-versions }}
path: githooks-${{ matrix.php-versions }}.tar
test_rc:
name: Test the Build (${{ matrix.operating-system }} php ${{ matrix.php-versions }})
runs-on: ${{ matrix.operating-system }}
needs: build_rc
strategy:
fail-fast: false
matrix:
include:
- operating-system: ubuntu-latest
php-versions: '7.4'
- operating-system: ubuntu-latest
php-versions: '8.0'
- operating-system: ubuntu-latest
php-versions: '8.5'
# macOS smoke against the compiled .phar — guarantees the
# bundled binary boots on Darwin and that the macOS RSS sampler
# works end-to-end before publishing the release. One runner
# per rc is cheap; the cost only fires on push to rc** branches.
- operating-system: macos-latest
php-versions: '8.5'
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-versions }}
tools: phpcs, phpcbf, phpmd, phpstan, parallel-Lint, phpcpd
coverage: none
- name: Cache dependencies
uses: actions/cache@v4
with:
path: |
/home/runner/.cache/composer/files
key: ${{ runner.os }}-${{ matrix.php-versions }}-${{ hashFiles('**/composer.json') }}
restore-keys: |
${{ runner.os }}-
# Install dependencies for run phpunit
- name: Install dependencies
env:
COMPOSER_AUTH: '{}'
run: |
rm -f ~/.composer/auth.json ~/.config/composer/auth.json
composer install --prefer-dist --no-progress
chmod -R +x tools/*
- uses: actions/download-artifact@v4
with:
path: ${{ github.GITHUB_WORKSPACE }}
- name: Display structure of downloaded files
run: ls -R | grep githooks
- name: Extract and check build
run: php githooks app:extract-build
# Smoke test: verifies that the compiled .phar actually boots as a standalone
# binary for a real user. Picks the correct tier based on the runner's PHP
# version (builds/php7.4/ for 7.4/8.0, builds/ for 8.1+). `--group release`
# exercises the library code but does not cover the binary's startup path.
- name: Smoke test — .phar boots and responds to basic commands
shell: bash
run: |
case "${{ matrix.php-versions }}" in
7.4|8.0) PHAR="builds/php7.4/githooks" ;;
*) PHAR="builds/githooks" ;;
esac
echo -e "\e[42m\e[30m**** Smoke test: $PHAR on PHP $(php -r 'echo PHP_VERSION;') ****\033[0m"
php "$PHAR" --version
php "$PHAR" --help > /dev/null
php "$PHAR" system:info
- name: Testing the Aplication
shell: bash
run: |
echo -e "\e[42m\e[30m**** Release Test Suite ****\033[0m"
# macos-latest reports `sh: /bin/true: No such file or directory` on
# custom jobs that invoke /bin/true by absolute path; the fixtures were
# migrated to bare `true` so the cross-OS suite is uniform. Darwin runs
# both groups: --group release for parity, plus --group release-macos
# for the per-platform regression net (see MacOsReleaseTest).
if [[ "${{ runner.os }}" == "macOS" ]]; then
vendor/bin/phpunit --group release,release-macos
else
vendor/bin/phpunit --group release
fi
commit_rc:
name: Commit the Build
needs: test_rc
runs-on: ubuntu-latest
strategy:
matrix:
operating-system: [ubuntu-latest]
php-versions: ['7.4']
permissions:
contents: write
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-versions }}
coverage: none
- name: Get composer cache directory
id: composer-cache
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
- name: Cache dependencies
uses: actions/cache@v4
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-rc-${{ matrix.php-versions }}-${{ hashFiles('**/composer.json') }}
restore-keys: |
${{ runner.os }}-
- name: Install dependencies
env:
COMPOSER_AUTH: '{}'
run: |
rm -f ~/.composer/auth.json ~/.config/composer/auth.json
chmod -R +x tools/*
tools/composer install --prefer-dist --no-progress
- name: Delete Old Builds
run: rm builds/githooks builds/php7.4/githooks
- uses: actions/download-artifact@v4
with:
path: ${{ github.GITHUB_WORKSPACE }}
- name: Display structure of downloaded files
run: |
ls -R | grep githooks
ls
- name: Extract and check builds
run: |
php githooks app:extract-build --all
# tar -xvf githooks-7.1/githooks-7.1.tar
# tar -xvf githooks-7.3/githooks-7.3.tar
# tar -xvf githooks-8.1/githooks-8.1.tar
ls -lah builds
git status
- name: Get Time
id: time
uses: nanzm/get-time-action@v2.0
with:
timeZone: 1
format: 'DD-MM-YYYY HH:mm:ss'
- name: Extract version
id: version_id
run: |
branch=${GITHUB_REF##*/}
echo ${branch}
prefix='rc-'
version=${branch#"$prefix"}
echo $version
echo "version=$version" >> $GITHUB_OUTPUT
- name: Check Version
run: echo ${{ steps.version_id.outputs.version }} && echo ${{ steps.time.outputs.time }}
- name: Disable pre-commit hook for CI build commit
run: git config --unset core.hooksPath || true
- uses: GuillaumeFalourd/git-commit-push@v1.3
with:
files: builds/githooks builds/php7.4/githooks
commit_message: 'Release Candidate: ${{ steps.version_id.outputs.version }} - Build: ${{ steps.time.outputs.time }}'
- name: Check the commit
run: git log