@@ -16,10 +16,10 @@ jobs:
1616 if : ${{ github.repository_owner == 'wp-cli' }}
1717 steps :
1818 - name : Check out source code
19- uses : actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
19+ uses : actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
2020
2121 - name : Set up PHP environment
22- uses : shivammathur/setup-php@accd6127cb78bee3e8082180cb391013d204ef9f # v2
22+ uses : shivammathur/setup-php@f3e473d116dcccaddc5834248c87452386958240 # v2
2323 with :
2424 php-version : ' latest'
2525 extensions : mysql, zip, imagick
7474 strategy :
7575 fail-fast : false
7676 matrix :
77- php : ['7.2 ', '7.3', '7.4', '8.5 ']
77+ php : ['8.5 ', '7.4 ']
7878 wp : ['latest']
7979 mysql : ['8.0']
8080 include :
9999 - php : ' 7.2'
100100 wp : ' 4.9'
101101 mysql : ' 5.6'
102+ - php : ' 7.2'
103+ wp : ' 6.9'
104+ mysql : ' 8.0'
102105 runs-on : ubuntu-22.04
103106 env :
104107 WP_CLI_BIN_DIR : /tmp/wp-cli-phar
@@ -107,15 +110,15 @@ jobs:
107110 if : ${{ github.repository_owner == 'wp-cli' }}
108111 steps :
109112 - name : Check out source code
110- uses : actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
113+ uses : actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
111114
112115 - name : Install Ghostscript
113116 run : |
114117 sudo apt-get update
115118 sudo apt-get install ghostscript -y
116119
117120 - name : Set up PHP environment
118- uses : shivammathur/setup-php@accd6127cb78bee3e8082180cb391013d204ef9f # v2
121+ uses : shivammathur/setup-php@f3e473d116dcccaddc5834248c87452386958240 # v2
119122 with :
120123 php-version : ' ${{ matrix.php }}'
121124 extensions : imagick, mysql, zip
@@ -137,7 +140,7 @@ jobs:
137140 sudo sed -i 's/^.*policy.*coder.*none.*PDF.*//' /etc/ImageMagick-6/policy.xml
138141
139142 - name : Download built Phar file
140- uses : actions/download-artifact@v8
143+ uses : actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8
141144 with :
142145 name : wp-cli-phar
143146
@@ -149,7 +152,7 @@ jobs:
149152
150153 - name : Setup MySQL Server
151154 id : setup-mysql
152- uses : shogo82148/actions-setup-mysql@840178c12b07a58353c6312be784c23b63756eea # v1
155+ uses : shogo82148/actions-setup-mysql@3dcedf762c5e82d781a9e414462785b30208e79c # v1
153156 with :
154157 mysql-version : ${{ matrix.mysql }}
155158 auto-start : true
@@ -189,13 +192,13 @@ jobs:
189192 if : ${{ github.repository_owner == 'wp-cli' && github.event_name != 'workflow_dispatch' }}
190193 steps :
191194 - name : Check out builds repository
192- uses : actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
195+ uses : actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
193196 with :
194197 repository : wp-cli/builds
195198 token : ${{ secrets.ACTIONS_BOT }}
196199
197200 - name : Download WP-CLI version
198- uses : actions/download-artifact@v8
201+ uses : actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8
199202 with :
200203 name : cli_version
201204
@@ -204,12 +207,12 @@ jobs:
204207 cat cli_version.txt > phar/NIGHTLY_VERSION
205208
206209 - name : Download manifest file
207- uses : actions/download-artifact@v8
210+ uses : actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8
208211 with :
209212 name : manifest
210213
211214 - name : Download built Phar file
212- uses : actions/download-artifact@v8
215+ uses : actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8
213216 with :
214217 name : wp-cli-phar
215218
@@ -250,7 +253,7 @@ jobs:
250253 git commit -m "phar build: $GITHUB_REPOSITORY@$GITHUB_SHA"
251254
252255 - name : Push changes
253- uses : ad-m/github-push-action@master
256+ uses : ad-m/github-push-action@881a6320fdb16eb5318c5054f31c218aec2b324c # v1
254257 with :
255258 github_token : ${{ secrets.ACTIONS_BOT }}
256259 branch : gh-pages
@@ -264,13 +267,21 @@ jobs:
264267
265268 steps :
266269 - name : Check out builds repository
267- uses : actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
270+ uses : actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
268271 with :
269272 repository : wp-cli/builds
270273 token : ${{ secrets.ACTIONS_BOT }}
271274
275+ - name : Check out bundle repository
276+ uses : actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
277+ with :
278+ repository : ${{ github.repository }}
279+ ref : ${{ github.sha }}
280+ path : bundle
281+ persist-credentials : false
282+
272283 - name : Download built Phar file
273- uses : actions/download-artifact@v8
284+ uses : actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8
274285 with :
275286 name : wp-cli-phar
276287
@@ -279,18 +290,45 @@ jobs:
279290 sudo apt-get update
280291 sudo apt-get install rpm rpmlint -y
281292
282- - name : Download RPM build configuration
293+ - name : Copy RPM build configuration
283294 run : |
284- wget -O wp-cli-rpm.spec https://raw.githubusercontent.com/wp-cli/wp-cli- bundle/main/ utils/wp-cli-rpm.spec
285- wget -O wp-cli-updaterpm.sh https://raw.githubusercontent.com/wp-cli/wp-cli- bundle/main/ utils/wp-cli-updaterpm.sh
295+ cp bundle/utils/wp-cli-rpm.spec .
296+ cp bundle/utils/wp-cli-updaterpm.sh .
286297
287298 - name : Build RPM package
288299 run : |
289300 bash wp-cli-updaterpm.sh
290301
291302 - name : Verify built RPM package contents
292303 run : |
293- ls rpm-src/noarch
304+ set -euxo pipefail
305+ rpm_file="$(ls rpm-src/noarch/wp-cli-*.noarch.rpm)"
306+ # The package must ship a launcher in the bin dir and the Phar in the data dir.
307+ rpm -qlp "$rpm_file" | tee /tmp/rpm-files.txt
308+ grep -qx '/usr/bin/wp' /tmp/rpm-files.txt
309+ grep -qx '/usr/share/wp-cli/wp-cli.phar' /tmp/rpm-files.txt
310+ # /usr/bin/wp must be the shell launcher that honors WP_CLI_PHP / WP_CLI_PHP_ARGS,
311+ # not the Phar itself.
312+ mkdir -p rpm-verify
313+ ( cd rpm-verify && rpm2cpio "../$rpm_file" | cpio -idm )
314+ test -x rpm-verify/usr/bin/wp
315+ head -n1 rpm-verify/usr/bin/wp | grep -q '^#!/bin/sh'
316+ grep -q '/usr/share/wp-cli/wp-cli.phar' rpm-verify/usr/bin/wp
317+ test -s rpm-verify/usr/share/wp-cli/wp-cli.phar
318+ # Run the extracted launcher through a probe standing in for PHP: it must
319+ # forward WP_CLI_PHP_ARGS before the Phar and export WP_CLI_PHP_USED. The
320+ # probe asserts and exits without needing the Phar at its installed path.
321+ printf '%s\n' \
322+ '#!/bin/sh' \
323+ 'case " $* " in' \
324+ ' *" -d memory_limit=256M "*) : ;;' \
325+ ' *) echo "WP_CLI_PHP_ARGS not forwarded: $*" >&2; exit 3 ;;' \
326+ 'esac' \
327+ '[ -n "$WP_CLI_PHP_USED" ] || { echo "WP_CLI_PHP_USED not exported" >&2; exit 4; }' \
328+ 'exit 0' \
329+ > /tmp/wp-cli-php-probe
330+ chmod +x /tmp/wp-cli-php-probe
331+ WP_CLI_PHP=/tmp/wp-cli-php-probe WP_CLI_PHP_ARGS="-d memory_limit=256M" rpm-verify/usr/bin/wp cli version
294332
295333 - name : Copy RPM package into builds folder
296334 run : |
@@ -304,7 +342,7 @@ jobs:
304342 git commit -m "rpm build: $GITHUB_REPOSITORY@$GITHUB_SHA"
305343
306344 - name : Push changes
307- uses : ad-m/github-push-action@master
345+ uses : ad-m/github-push-action@881a6320fdb16eb5318c5054f31c218aec2b324c # v1
308346 with :
309347 github_token : ${{ secrets.ACTIONS_BOT }}
310348 branch : gh-pages
@@ -318,13 +356,21 @@ jobs:
318356
319357 steps :
320358 - name : Check out builds repository
321- uses : actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
359+ uses : actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
322360 with :
323361 repository : wp-cli/builds
324362 token : ${{ secrets.ACTIONS_BOT }}
325363
364+ - name : Check out bundle repository
365+ uses : actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
366+ with :
367+ repository : ${{ github.repository }}
368+ ref : ${{ github.sha }}
369+ path : bundle
370+ persist-credentials : false
371+
326372 - name : Download built Phar file
327- uses : actions/download-artifact@v8
373+ uses : actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8
328374 with :
329375 name : wp-cli-phar
330376
@@ -333,17 +379,50 @@ jobs:
333379 sudo apt-get update
334380 sudo apt-get install fakeroot lintian -y
335381
336- - name : Download DEB build configuration
382+ - name : Copy DEB build configuration
337383 run : |
338- wget -O wp-cli-updatedeb.sh https://raw.githubusercontent.com/wp-cli/wp-cli- bundle/main/ utils/wp-cli-updatedeb.sh
384+ cp bundle/utils/wp-cli-updatedeb.sh .
339385
340386 - name : Build DEB package
341387 run : |
342388 bash wp-cli-updatedeb.sh
343389
344390 - name : Verify built DEB package contents
345391 run : |
346- ls .
392+ set -euxo pipefail
393+ deb_file="$(ls php-wpcli*all.deb)"
394+ # The package must ship a launcher in the bin dir and the Phar in the data dir.
395+ dpkg-deb -c "$deb_file" | tee /tmp/deb-files.txt
396+ grep -Eq ' \./usr/bin/wp$' /tmp/deb-files.txt
397+ grep -Eq ' \./usr/share/wp-cli/wp-cli.phar$' /tmp/deb-files.txt
398+ # Install the package and exercise the launcher (php ships on the runner).
399+ sudo dpkg -i "$deb_file" || sudo apt-get install -f -y
400+ test -x /usr/bin/wp
401+ head -n1 /usr/bin/wp | grep -q '^#!/bin/sh'
402+ test -s /usr/share/wp-cli/wp-cli.phar
403+ # Default interpreter works.
404+ wp --info
405+ wp cli version
406+ # A probe that stands in for PHP and asserts what the launcher forwarded:
407+ # it must receive WP_CLI_PHP_ARGS before the Phar and inherit WP_CLI_PHP_USED.
408+ printf '%s\n' \
409+ '#!/bin/sh' \
410+ 'case " $* " in' \
411+ ' *" -d memory_limit=256M "*) : ;;' \
412+ ' *) echo "WP_CLI_PHP_ARGS not forwarded: $*" >&2; exit 3 ;;' \
413+ 'esac' \
414+ '[ -n "$WP_CLI_PHP_USED" ] || { echo "WP_CLI_PHP_USED not exported" >&2; exit 4; }' \
415+ 'exit 0' \
416+ > /tmp/wp-cli-php-probe
417+ chmod +x /tmp/wp-cli-php-probe
418+ # Proves WP_CLI_PHP selects the interpreter AND WP_CLI_PHP_ARGS reaches it.
419+ WP_CLI_PHP=/tmp/wp-cli-php-probe WP_CLI_PHP_ARGS="-d memory_limit=256M" wp cli version
420+ # A deliberately broken WP_CLI_PHP must actually be used: if it were ignored,
421+ # this would still succeed. This is the regression guard for the whole fix.
422+ if WP_CLI_PHP=/bin/false wp cli version 2>/dev/null; then
423+ echo "WP_CLI_PHP was ignored by the launcher" >&2
424+ exit 1
425+ fi
347426
348427 - name : Copy DEB package into builds folder
349428 run : |
@@ -357,7 +436,7 @@ jobs:
357436 git commit -m "deb build: $GITHUB_REPOSITORY@$GITHUB_SHA"
358437
359438 - name : Push changes
360- uses : ad-m/github-push-action@master
439+ uses : ad-m/github-push-action@881a6320fdb16eb5318c5054f31c218aec2b324c # v1
361440 with :
362441 github_token : ${{ secrets.ACTIONS_BOT }}
363442 branch : gh-pages
0 commit comments