Skip to content

Commit e18503d

Browse files
committed
GH Actions/verify release: tweak the workflow [2]
PHIVE does not support a "stability" flag yet, which means that it will always grab the very latest release, even when this is an alpha/beta/RC pre-release. As the GH API `releases/latest` route returns the latest _stable_ release, this causes the workflow to fail. This was already previously identified as an area which needed attention in #758, and as we now have a pre-release as the latest release (`4.0.0beta1`), this now needs to be fixed. Note: this still doesn't fix things completely, as in reality, the workflow should work based on the tag published if the workflow is triggered by a release to ensure that the "release assets" and "versioned web" jobs check the right release ("unversioned web" should still always check the latest stable release), but it is unclear where to grab that info from and as testing the info available when the workflow is triggered by a release requires doing a release, this is neigh impossible to test. I may need to create a dummy repo just to test. For now, this at least fixes the Phive jobs.
1 parent 45b7a3a commit e18503d

File tree

1 file changed

+16
-12
lines changed

1 file changed

+16
-12
lines changed

.github/workflows/verify-release.yml

+16-12
Original file line numberDiff line numberDiff line change
@@ -148,24 +148,28 @@ jobs:
148148
name: "PHIVE: ${{ matrix.pharfile }}"
149149

150150
steps:
151-
- name: Retrieve latest release info
152-
uses: octokit/[email protected]
153-
id: get_latest_release
154-
with:
155-
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"
156160
env:
157161
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
158162

159-
- name: "DEBUG: Show API request failure status"
160-
if: ${{ failure() }}
161-
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 }}"
162165

163-
- 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
164168
id: version
165-
run: |
166-
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"
167171

168-
- name: "DEBUG: Show tag name found in API response"
172+
- name: "DEBUG: Show cleaned up tag name"
169173
run: "echo ${{ steps.version.outputs.TAG }}"
170174

171175
- name: Setup PHP

0 commit comments

Comments
 (0)