1616 if : ${{ github.repository_owner == 'wp-cli' }}
1717 steps :
1818 - name : Check out source code
19- uses : actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
19+ uses : actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
2020
2121 - name : Set up PHP environment
2222 uses : shivammathur/setup-php@f3e473d116dcccaddc5834248c87452386958240 # v2
@@ -110,7 +110,7 @@ jobs:
110110 if : ${{ github.repository_owner == 'wp-cli' }}
111111 steps :
112112 - name : Check out source code
113- uses : actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
113+ uses : actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
114114
115115 - name : Install Ghostscript
116116 run : |
@@ -140,7 +140,7 @@ jobs:
140140 sudo sed -i 's/^.*policy.*coder.*none.*PDF.*//' /etc/ImageMagick-6/policy.xml
141141
142142 - name : Download built Phar file
143- uses : actions/download-artifact@v8
143+ uses : actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8
144144 with :
145145 name : wp-cli-phar
146146
@@ -152,7 +152,7 @@ jobs:
152152
153153 - name : Setup MySQL Server
154154 id : setup-mysql
155- uses : shogo82148/actions-setup-mysql@076e636c45996ec8cb1a455c65f9f5364aeebd8a # v1
155+ uses : shogo82148/actions-setup-mysql@3dcedf762c5e82d781a9e414462785b30208e79c # v1
156156 with :
157157 mysql-version : ${{ matrix.mysql }}
158158 auto-start : true
@@ -192,13 +192,13 @@ jobs:
192192 if : ${{ github.repository_owner == 'wp-cli' && github.event_name != 'workflow_dispatch' }}
193193 steps :
194194 - name : Check out builds repository
195- uses : actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
195+ uses : actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
196196 with :
197197 repository : wp-cli/builds
198198 token : ${{ secrets.ACTIONS_BOT }}
199199
200200 - name : Download WP-CLI version
201- uses : actions/download-artifact@v8
201+ uses : actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8
202202 with :
203203 name : cli_version
204204
@@ -207,12 +207,12 @@ jobs:
207207 cat cli_version.txt > phar/NIGHTLY_VERSION
208208
209209 - name : Download manifest file
210- uses : actions/download-artifact@v8
210+ uses : actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8
211211 with :
212212 name : manifest
213213
214214 - name : Download built Phar file
215- uses : actions/download-artifact@v8
215+ uses : actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8
216216 with :
217217 name : wp-cli-phar
218218
@@ -253,7 +253,7 @@ jobs:
253253 git commit -m "phar build: $GITHUB_REPOSITORY@$GITHUB_SHA"
254254
255255 - name : Push changes
256- uses : ad-m/github-push-action@master
256+ uses : ad-m/github-push-action@881a6320fdb16eb5318c5054f31c218aec2b324c # v1
257257 with :
258258 github_token : ${{ secrets.ACTIONS_BOT }}
259259 branch : gh-pages
@@ -311,13 +311,21 @@ jobs:
311311
312312 steps :
313313 - name : Check out builds repository
314- uses : actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
314+ uses : actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
315315 with :
316316 repository : wp-cli/builds
317317 token : ${{ secrets.ACTIONS_BOT }}
318318
319+ - name : Check out bundle repository
320+ uses : actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
321+ with :
322+ repository : ${{ github.repository }}
323+ ref : ${{ github.sha }}
324+ path : bundle
325+ persist-credentials : false
326+
319327 - name : Download built Phar file
320- uses : actions/download-artifact@v8
328+ uses : actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8
321329 with :
322330 name : wp-cli-phar
323331
@@ -326,18 +334,45 @@ jobs:
326334 sudo apt-get update
327335 sudo apt-get install rpm rpmlint -y
328336
329- - name : Download RPM build configuration
337+ - name : Copy RPM build configuration
330338 run : |
331- wget -O wp-cli-rpm.spec https://raw.githubusercontent.com/wp-cli/wp-cli- bundle/main/ utils/wp-cli-rpm.spec
332- wget -O wp-cli-updaterpm.sh https://raw.githubusercontent.com/wp-cli/wp-cli- bundle/main/ utils/wp-cli-updaterpm.sh
339+ cp bundle/utils/wp-cli-rpm.spec .
340+ cp bundle/utils/wp-cli-updaterpm.sh .
333341
334342 - name : Build RPM package
335343 run : |
336344 bash wp-cli-updaterpm.sh
337345
338346 - name : Verify built RPM package contents
339347 run : |
340- ls rpm-src/noarch
348+ set -euxo pipefail
349+ rpm_file="$(ls rpm-src/noarch/wp-cli-*.noarch.rpm)"
350+ # The package must ship a launcher in the bin dir and the Phar in the data dir.
351+ rpm -qlp "$rpm_file" | tee /tmp/rpm-files.txt
352+ grep -qx '/usr/bin/wp' /tmp/rpm-files.txt
353+ grep -qx '/usr/share/wp-cli/wp-cli.phar' /tmp/rpm-files.txt
354+ # /usr/bin/wp must be the shell launcher that honors WP_CLI_PHP / WP_CLI_PHP_ARGS,
355+ # not the Phar itself.
356+ mkdir -p rpm-verify
357+ ( cd rpm-verify && rpm2cpio "../$rpm_file" | cpio -idm )
358+ test -x rpm-verify/usr/bin/wp
359+ head -n1 rpm-verify/usr/bin/wp | grep -q '^#!/bin/sh'
360+ grep -q '/usr/share/wp-cli/wp-cli.phar' rpm-verify/usr/bin/wp
361+ test -s rpm-verify/usr/share/wp-cli/wp-cli.phar
362+ # Run the extracted launcher through a probe standing in for PHP: it must
363+ # forward WP_CLI_PHP_ARGS before the Phar and export WP_CLI_PHP_USED. The
364+ # probe asserts and exits without needing the Phar at its installed path.
365+ printf '%s\n' \
366+ '#!/bin/sh' \
367+ 'case " $* " in' \
368+ ' *" -d memory_limit=256M "*) : ;;' \
369+ ' *) echo "WP_CLI_PHP_ARGS not forwarded: $*" >&2; exit 3 ;;' \
370+ 'esac' \
371+ '[ -n "$WP_CLI_PHP_USED" ] || { echo "WP_CLI_PHP_USED not exported" >&2; exit 4; }' \
372+ 'exit 0' \
373+ > /tmp/wp-cli-php-probe
374+ chmod +x /tmp/wp-cli-php-probe
375+ WP_CLI_PHP=/tmp/wp-cli-php-probe WP_CLI_PHP_ARGS="-d memory_limit=256M" rpm-verify/usr/bin/wp cli version
341376
342377 - name : Copy RPM package into builds folder
343378 run : |
@@ -351,7 +386,7 @@ jobs:
351386 git commit -m "rpm build: $GITHUB_REPOSITORY@$GITHUB_SHA"
352387
353388 - name : Push changes
354- uses : ad-m/github-push-action@master
389+ uses : ad-m/github-push-action@881a6320fdb16eb5318c5054f31c218aec2b324c # v1
355390 with :
356391 github_token : ${{ secrets.ACTIONS_BOT }}
357392 branch : gh-pages
@@ -365,13 +400,21 @@ jobs:
365400
366401 steps :
367402 - name : Check out builds repository
368- uses : actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
403+ uses : actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
369404 with :
370405 repository : wp-cli/builds
371406 token : ${{ secrets.ACTIONS_BOT }}
372407
408+ - name : Check out bundle repository
409+ uses : actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
410+ with :
411+ repository : ${{ github.repository }}
412+ ref : ${{ github.sha }}
413+ path : bundle
414+ persist-credentials : false
415+
373416 - name : Download built Phar file
374- uses : actions/download-artifact@v8
417+ uses : actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8
375418 with :
376419 name : wp-cli-phar
377420
@@ -380,17 +423,50 @@ jobs:
380423 sudo apt-get update
381424 sudo apt-get install fakeroot lintian -y
382425
383- - name : Download DEB build configuration
426+ - name : Copy DEB build configuration
384427 run : |
385- wget -O wp-cli-updatedeb.sh https://raw.githubusercontent.com/wp-cli/wp-cli- bundle/main/ utils/wp-cli-updatedeb.sh
428+ cp bundle/utils/wp-cli-updatedeb.sh .
386429
387430 - name : Build DEB package
388431 run : |
389432 bash wp-cli-updatedeb.sh
390433
391434 - name : Verify built DEB package contents
392435 run : |
393- ls .
436+ set -euxo pipefail
437+ deb_file="$(ls php-wpcli*all.deb)"
438+ # The package must ship a launcher in the bin dir and the Phar in the data dir.
439+ dpkg-deb -c "$deb_file" | tee /tmp/deb-files.txt
440+ grep -Eq ' \./usr/bin/wp$' /tmp/deb-files.txt
441+ grep -Eq ' \./usr/share/wp-cli/wp-cli.phar$' /tmp/deb-files.txt
442+ # Install the package and exercise the launcher (php ships on the runner).
443+ sudo dpkg -i "$deb_file" || sudo apt-get install -f -y
444+ test -x /usr/bin/wp
445+ head -n1 /usr/bin/wp | grep -q '^#!/bin/sh'
446+ test -s /usr/share/wp-cli/wp-cli.phar
447+ # Default interpreter works.
448+ wp --info
449+ wp cli version
450+ # A probe that stands in for PHP and asserts what the launcher forwarded:
451+ # it must receive WP_CLI_PHP_ARGS before the Phar and inherit WP_CLI_PHP_USED.
452+ printf '%s\n' \
453+ '#!/bin/sh' \
454+ 'case " $* " in' \
455+ ' *" -d memory_limit=256M "*) : ;;' \
456+ ' *) echo "WP_CLI_PHP_ARGS not forwarded: $*" >&2; exit 3 ;;' \
457+ 'esac' \
458+ '[ -n "$WP_CLI_PHP_USED" ] || { echo "WP_CLI_PHP_USED not exported" >&2; exit 4; }' \
459+ 'exit 0' \
460+ > /tmp/wp-cli-php-probe
461+ chmod +x /tmp/wp-cli-php-probe
462+ # Proves WP_CLI_PHP selects the interpreter AND WP_CLI_PHP_ARGS reaches it.
463+ WP_CLI_PHP=/tmp/wp-cli-php-probe WP_CLI_PHP_ARGS="-d memory_limit=256M" wp cli version
464+ # A deliberately broken WP_CLI_PHP must actually be used: if it were ignored,
465+ # this would still succeed. This is the regression guard for the whole fix.
466+ if WP_CLI_PHP=/bin/false wp cli version 2>/dev/null; then
467+ echo "WP_CLI_PHP was ignored by the launcher" >&2
468+ exit 1
469+ fi
394470
395471 - name : Copy DEB package into builds folder
396472 run : |
@@ -404,7 +480,7 @@ jobs:
404480 git commit -m "deb build: $GITHUB_REPOSITORY@$GITHUB_SHA"
405481
406482 - name : Push changes
407- uses : ad-m/github-push-action@master
483+ uses : ad-m/github-push-action@881a6320fdb16eb5318c5054f31c218aec2b324c # v1
408484 with :
409485 github_token : ${{ secrets.ACTIONS_BOT }}
410486 branch : gh-pages
0 commit comments