forked from WordPress/wordpress-develop
-
Notifications
You must be signed in to change notification settings - Fork 0
155 lines (144 loc) · 5.93 KB
/
reusable-support-json-reader-v1.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
##
# A reusable workflow that reads the .version-support-*.json files and returns values for use in a
# test matrix based on a given WordPress version.
##
name: Determine test matrix values
on:
workflow_call:
inputs:
wp-version:
description: 'The WordPress version to test . Accepts major and minor versions, "latest", or "nightly". Major releases must not end with ".0".'
type: string
default: 'nightly'
repository:
description: 'The repository to read support JSON files from.'
type: string
default: 'WordPress/wordpress-develop'
outputs:
major-wp-version:
description: "The major WordPress version based on the version provided in wp-version"
value: ${{ jobs.major-wp-version.outputs.version }}
php-versions:
description: "The PHP versions to test for the given wp-version"
value: ${{ jobs.php-versions.outputs.versions }}
mysql-versions:
description: "The MySQL versions to test for the given wp-version"
value: ${{ jobs.mysql-versions.outputs.versions }}
# Disable permissions for all available scopes by default.
# Any needed permissions should be configured at the job level.
permissions: {}
jobs:
# Determines the major version of WordPress being tested.
#
# The data in the JSON files are indexed by major version, so this is used to look up the appropriate support policy.
#
# Performs the following steps:
# - Checks out the repository
# - Returns the major WordPress version as an output based on the value passed to the wp-version input.
major-wp-version:
name: Determine major WordPress version
permissions:
contents: read
runs-on: ubuntu-24.04
timeout-minutes: 5
outputs:
version: ${{ steps.major-wp-version.outputs.version }}
steps:
- name: Checkout repository
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
repository: ${{ inputs.repository }}
show-progress: ${{ runner.debug == '1' && 'true' || 'false' }}
persist-credentials: false
- name: Determine the major WordPress version
id: major-wp-version
run: |
if [ "${WP_VERSION}" ] && [ "${WP_VERSION}" != "nightly" ] && [ "${WP_VERSION}" != "latest" ] && [ "${WP_VERSION}" != "trunk" ]; then
echo "version=$(echo "${WP_VERSION}" | tr '.' '-' | cut -d '-' -f1-2)" >> "$GITHUB_OUTPUT"
elif [ "${WP_VERSION}" ] && [ "${WP_VERSION}" != "trunk" ]; then
echo "version=${WP_VERSION}" >> "$GITHUB_OUTPUT"
else
echo "version=nightly" >> "$GITHUB_OUTPUT"
fi
env:
WP_VERSION: ${{ inputs.wp-version }}
# Determines the versions of PHP supported for a version of WordPress.
#
# Performs the following steps:
# - Checks out the repository
# - Returns the versions of PHP supported for the major version of WordPress by parsing the
# .version-support-php.json file and returning the values in that version's index.
php-versions:
name: Determine PHP versions
permissions:
contents: read
runs-on: ubuntu-24.04
needs: [ major-wp-version ]
timeout-minutes: 5
outputs:
versions: ${{ steps.php-versions.outputs.versions }}
steps:
- name: Checkout repository
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
repository: ${{ inputs.repository }}
show-progress: ${{ runner.debug == '1' && 'true' || 'false' }}
persist-credentials: false
# Look up the major version's specific PHP support policy when a version is provided.
# Otherwise, use the current PHP support policy.
- name: Get supported PHP versions
id: php-versions
run: |
if [ "${WP_VERSION}" != "latest" ] && [ "${WP_VERSION}" != "nightly" ]; then
VERSIONS="$( jq \
-r \
--arg wp_version "${WP_VERSION}" \
'.[$wp_version] | @json' \
.version-support-php.json
)"
echo "versions=$VERSIONS" >> "$GITHUB_OUTPUT"
else
echo "versions=$(jq -r '.[ (keys[-1]) ] | @json' .version-support-php.json)" >> "$GITHUB_OUTPUT"
fi
env:
WP_VERSION: ${{ needs.major-wp-version.outputs.version }}
# Determines the versions of MySQL supported for a version of WordPress.
#
# Performs the following steps:
# - Checks out the repository
# - Returns the versions of MySQL supported for the major version of WordPress by parsing the
# .version-support-mysql.json file and returning the values in that version's index.
mysql-versions:
name: Determine MySQL versions
permissions:
contents: read
runs-on: ubuntu-24.04
needs: [ major-wp-version ]
timeout-minutes: 5
outputs:
versions: ${{ steps.mysql-versions.outputs.versions }}
steps:
- name: Checkout repository
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
repository: ${{ inputs.repository }}
show-progress: ${{ runner.debug == '1' && 'true' || 'false' }}
persist-credentials: false
# Look up the major version's specific MySQL support policy when a version is provided.
# Otherwise, use the current MySQL support policy.
- name: Get supported MySQL versions
id: mysql-versions
run: |
if [ "${WP_VERSION}" != "latest" ] && [ "${WP_VERSION}" != "nightly" ]; then
VERSIONS="$( jq \
-r \
--arg wp_version "${WP_VERSION}" \
'.[$wp_version] | @json' \
.version-support-mysql.json
)"
echo "versions=$VERSIONS" >> "$GITHUB_OUTPUT"
else
echo "versions=$(jq -r '.[ (keys[-1]) ] | @json' .version-support-mysql.json)" >> "$GITHUB_OUTPUT"
fi
env:
WP_VERSION: ${{ needs.major-wp-version.outputs.version }}