Skip to content

Commit 35d436e

Browse files
committed
feat: add input to control version validation level
Introduce the `validation-level` input, defaulting to `minor`. When `validation-level` is set to `minor`, the action truncates the current stable WordPress version (e.g., 6.5.3 becomes 6.5) before comparison. This ensures that validation passes if the plugin is tested up to the latest minor branch, regardless of subsequent patch releases.
1 parent 9cb142a commit 35d436e

File tree

3 files changed

+16
-2
lines changed

3 files changed

+16
-2
lines changed

README.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ jobs:
2323
with:
2424
fetch-depth: 0
2525
- name: Validate Plugin Version
26-
uses: jazzsequence/action-validate-plugin-version@v1
26+
uses: jazzsequence/action-validate-plugin-version@v2
2727
with:
2828
plugin-path: 'path/to/plugin-slug/'
2929
filenames: 'readme.txt,README.MD'
@@ -54,6 +54,9 @@ The branch to create the PR against. If not specified, the action will use the b
5454
#### `pr-status`
5555
The status to set on the PR. If not specified, the action will create a _draft_ PR. Accepts `draft` or `open`.
5656

57+
#### `validation-level`
58+
The validation level to use. Accepts `patch` or `minor`. If not specified, the action will use `minor`.
59+
5760
## Permissions
5861

5962
The `write` permissions on `contents` and `pull-requests` are important. They are required for the action to commit the changes back to the repository and open a pull request. The only files affected by the action are files named `readme.txt`, `README.md` or those files matching the pattern (looking for "Tested Up To" in the file) that have been specified in the `filenames` input.

action.yml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,10 @@ inputs:
2828
description: The status of the PR to create. Default is 'draft'. Accepts 'draft' or 'open'.
2929
required: false
3030
default: 'draft'
31+
validation-level:
32+
description: The validation level to use. Accepts 'patch' or 'minor'.
33+
required: false
34+
default: 'minor'
3135
runs:
3236
using: composite
3337
steps:
@@ -38,7 +42,7 @@ runs:
3842
echo "Current working directory:"
3943
pwd
4044
echo "Contents of action directory (looking for bin/validate-plugin-version.sh):"
41-
ls -R
45+
ls -R
4246
- name: Validate Plugin Tested Up To Version
4347
shell: bash
4448
env:
@@ -50,5 +54,6 @@ runs:
5054
BRANCH: ${{ inputs.branch }}
5155
PR_STATUS: ${{ inputs.pr-status }}
5256
GITHUB_BASE_REF: ${{ github.base_ref }}
57+
VALIDATION_LEVEL: ${{ inputs.validation-level }}
5358
run: bash ${{ github.action_path }}/bin/validate-plugin-version.sh
5459

bin/validate-plugin-version.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,12 @@ main() {
4848
CURRENT_WP_VERSION=$(curl -s https://api.wordpress.org/core/version-check/1.7/ | jq -r '.offers[0].current')
4949
echo "Current WordPress Version: ${CURRENT_WP_VERSION}"
5050

51+
# Adjust version based on validation level
52+
if [[ "${VALIDATION_LEVEL:-minor}" == "minor" ]]; then
53+
CURRENT_WP_VERSION=$(echo "$CURRENT_WP_VERSION" | cut -d'.' -f1,2)
54+
echo "Validation level is 'minor', using WordPress version: ${CURRENT_WP_VERSION}"
55+
fi
56+
5157
# Split FILENAMES into an array
5258
IFS=',' read -ra FILENAMES_ARRAY <<< "$FILENAMES"
5359

0 commit comments

Comments
 (0)