Skip to content

Commit 077509c

Browse files
malithsendaledupreez
authored andcommitted
Fix get-wordpress-plugin-version action (#4511)
* Fix version sorting * Add changelog entry * Update changelog entry Co-authored-by: Wesley Rosa <[email protected]> * Update changelog entry Co-authored-by: Wesley Rosa <[email protected]> * Update code comment * Fix changelogs --------- Co-authored-by: Wesley Rosa <[email protected]> Cherry-picked from 0eb61e3
1 parent 1d0ae23 commit 077509c

File tree

3 files changed

+13
-5
lines changed

3 files changed

+13
-5
lines changed

.github/actions/get-wordpress-plugin-versions/action.yml

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,14 +38,20 @@ runs:
3838
id: get-versions-json
3939
shell: bash
4040
# jq does the following:
41-
# - filters the versions to only include x.y.z versions, i.e. ignoring beta, rc, and dev versions etc
42-
# - groups the versions by the first two parts of the version number, i.e. major.minor
43-
# - reverses the order of the versions, so the highest major.minor versions are first
44-
# - limits the number of major.versions to the number specified in the version-count input
41+
# - filters the versions to only include semantic releases (x.y.z), ignoring beta, rc, trunk, etc.
42+
# - maps each version into a structure with:
43+
# - major_minor: the major.minor part (e.g. "9.6")
44+
# - full: the full version string (e.g. "9.6.2")
45+
# - parts: a numeric array of the version (e.g. [9, 6, 2])
46+
# - groups the versions by major.minor
47+
# - selects the highest patch version (i.e. max patch) within each group
48+
# - sorts all selected versions by semantic version order, descending
49+
# - limits the result to the latest N major.minor groups, where N is from version-count input
4550
# - returns the last version for each major.minor version
4651
run: |
4752
echo 'versions-json<<EOF' >> $GITHUB_OUTPUT
48-
cat ${{ inputs.plugin-slug }}.json | jq '.versions | keys | map( select( test("^\\d+\\.\\d+\\.\\d+$"; "s") ) ) | group_by( split( "." ) | .[0:2] | join( "." ) ) | reverse | .[0:${{ inputs.version-count }}] | [.[][-1]]' >> $GITHUB_OUTPUT
53+
cat ${{ inputs.plugin-slug }}.json | jq --argjson count "${{ inputs.version-count }}" '.versions | keys | map(select(test("^\\d+\\.\\d+\\.\\d+$"))) | map({ major_minor: (split(".")[0:2] | join(".")), full: ., parts: (split(".") | map(tonumber)) })
54+
| group_by(.major_minor) | map(max_by(.parts[2])) | sort_by(.parts[0], .parts[1], .parts[2]) | reverse | .[0:$count] | map(.full) ' >> $GITHUB_OUTPUT
4955
echo 'EOF' >> $GITHUB_OUTPUT
5056
5157
- name: Get versions in text format

changelog.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
* Fix - Prevent multiple save appearance AJAX calls on Block Checkout
77
* Fix - Fix required field error message and PHP warning for custom checkout fields that don't have a label
88
* Fix - Fix fatal when processing setup intents for free subscriptions via webhooks
9+
* Dev - Fix WooCommerce version fetching in GitHub workflows
910

1011
= 9.7.0 - 2025-07-21 =
1112
* Update - Removes BNPL payment methods (Klarna and Affirm) when other official plugins are active

readme.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@ If you get stuck, you can ask for help in the [Plugin Forum](https://wordpress.o
116116
* Fix - Prevent multiple save appearance AJAX calls on Block Checkout
117117
* Fix - Fix required field error message and PHP warning for custom checkout fields that don't have a label
118118
* Fix - Fix fatal when processing Boleto setup intents via webhooks
119+
* Dev - Fix WooCommerce version fetching in GitHub workflows
119120

120121
= 9.7.0 - 2025-07-21 =
121122

0 commit comments

Comments
 (0)