@@ -38,14 +38,20 @@ runs:
38
38
id : get-versions-json
39
39
shell : bash
40
40
# 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
45
50
# - returns the last version for each major.minor version
46
51
run : |
47
52
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
49
55
echo 'EOF' >> $GITHUB_OUTPUT
50
56
51
57
- name : Get versions in text format
0 commit comments