2727 verify-available-downloads :
2828 runs-on : ubuntu-latest
2929
30- # Only run this workflow in the context of this repo.
31- if : github.repository_owner == 'PHPCSStandards'
30+ # Only run this workflow in the context of this repo.
31+ if : github.repository_owner == 'PHPCSStandards'
3232
3333 strategy :
3434 fail-fast : false
@@ -109,9 +109,11 @@ jobs:
109109 ini-values : error_reporting=-1, display_errors=On
110110 coverage : none
111111
112- # Note: the `.` is in the command to make it work for both PHPCS as well PHPCBF.
112+ - name : Create a PHP file
113+ run : echo '<?php echo "Hello, World!";' > hello.php
114+
113115 - name : Verify the PHAR is nominally functional
114- run : php ${{ steps.source.outputs.FILE }} . -e --standard=PSR12
116+ run : php ${{ steps.source.outputs.FILE }} -- -ps hello.php --standard=PSR2
115117
116118 - name : Grab the version
117119 id : asset_version
@@ -133,8 +135,8 @@ jobs:
133135 verify-phive :
134136 runs-on : ubuntu-latest
135137
136- # Only run this workflow in the context of this repo.
137- if : github.repository_owner == 'PHPCSStandards'
138+ # Only run this workflow in the context of this repo.
139+ if : github.repository_owner == 'PHPCSStandards'
138140
139141 strategy :
140142 fail-fast : false
@@ -146,24 +148,28 @@ jobs:
146148 name : " PHIVE: ${{ matrix.pharfile }}"
147149
148150 steps :
149- - name : Retrieve latest release info
150- uses : octokit/request-action@v2.x
151- id : get_latest_release
152- with :
153- route : GET /repos/PHPCSStandards/PHP_CodeSniffer/releases/latest
151+ # Phive does not support a stability flag yet, so it will always download the
152+ # very latest release, even when this is a pre-release.
153+ # I.e. to verify the downloaded version, we need to select the version number including pre-releases.
154+ # Ref: https://github.com/phar-io/phive/issues/154
155+ - name : Retrieve latest release info (including prereleases)
156+ id : latest_release
157+ run : |
158+ latestRelease="$(gh release list --repo PHPCSStandards/PHP_CodeSniffer --limit 1 --json tagName --jq '.[0].tagName')"
159+ echo "TAG=$latestRelease" >> "$GITHUB_OUTPUT"
154160 env :
155161 GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
156162
157- - name : " DEBUG: Show API request failure status"
158- if : ${{ failure() }}
159- run : " echo No release found. Request failed with status ${{ steps.get_latest_release.outputs.status }}"
163+ - name : " DEBUG: Show tag name found in API response"
164+ run : " echo ${{ steps.latest_release.outputs.TAG }}"
160165
161- - name : Grab latest tag name from API response
166+ # Just get the version number, without alpha/beta/RC.
167+ - name : Clean up the version number
162168 id : version
163- run : |
164- echo "TAG=${{ fromJson( steps.get_latest_release .outputs.data).tag_name }}" >> "$GITHUB_OUTPUT"
169+ # yamllint disable-line rule:line-length
170+ run : echo "TAG=$(echo '$ {{ steps.latest_release .outputs.TAG }}' | grep --only-matching --max-count=1 --extended-regexp '\b[0-9]+(\.[0-9]+)+') " >> "$GITHUB_OUTPUT"
165171
166- - name : " DEBUG: Show tag name found in API response "
172+ - name : " DEBUG: Show cleaned up tag name "
167173 run : " echo ${{ steps.version.outputs.TAG }}"
168174
169175 - name : Setup PHP
@@ -186,9 +192,11 @@ jobs:
186192 GH_TOKEN : ${{ github.token }}
187193 GH_FORCE_TTY : true
188194
189- # Note: the `.` is in the command to make it work for both PHPCS as well PHPCBF.
195+ - name : Create a PHP file
196+ run : echo '<?php echo "Hello, World!";' > hello.php
197+
190198 - name : Verify the PHAR is nominally functional
191- run : php ./tools/${{ matrix.pharfile }} . -e --standard=PSR12
199+ run : php ./tools/${{ matrix.pharfile }} -- -ps hello.php --standard=PSR2
192200
193201 - name : Grab the version
194202 id : asset_version
0 commit comments