From 35d436e3b05b7cc3de7e13b978d003a61931cf71 Mon Sep 17 00:00:00 2001 From: Chris Reynolds Date: Thu, 30 Oct 2025 15:35:19 -0600 Subject: [PATCH 1/5] 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. --- README.md | 5 ++++- action.yml | 7 ++++++- bin/validate-plugin-version.sh | 6 ++++++ 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index f91561f..dcb6e0c 100644 --- a/README.md +++ b/README.md @@ -23,7 +23,7 @@ jobs: with: fetch-depth: 0 - name: Validate Plugin Version - uses: jazzsequence/action-validate-plugin-version@v1 + uses: jazzsequence/action-validate-plugin-version@v2 with: plugin-path: 'path/to/plugin-slug/' 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 #### `pr-status` The status to set on the PR. If not specified, the action will create a _draft_ PR. Accepts `draft` or `open`. +#### `validation-level` +The validation level to use. Accepts `patch` or `minor`. If not specified, the action will use `minor`. + ## Permissions 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. diff --git a/action.yml b/action.yml index d631da2..f66cf0b 100644 --- a/action.yml +++ b/action.yml @@ -28,6 +28,10 @@ inputs: description: The status of the PR to create. Default is 'draft'. Accepts 'draft' or 'open'. required: false default: 'draft' + validation-level: + description: The validation level to use. Accepts 'patch' or 'minor'. + required: false + default: 'minor' runs: using: composite steps: @@ -38,7 +42,7 @@ runs: echo "Current working directory:" pwd echo "Contents of action directory (looking for bin/validate-plugin-version.sh):" - ls -R + ls -R - name: Validate Plugin Tested Up To Version shell: bash env: @@ -50,5 +54,6 @@ runs: BRANCH: ${{ inputs.branch }} PR_STATUS: ${{ inputs.pr-status }} GITHUB_BASE_REF: ${{ github.base_ref }} + VALIDATION_LEVEL: ${{ inputs.validation-level }} run: bash ${{ github.action_path }}/bin/validate-plugin-version.sh \ No newline at end of file diff --git a/bin/validate-plugin-version.sh b/bin/validate-plugin-version.sh index 6c450f4..107a191 100644 --- a/bin/validate-plugin-version.sh +++ b/bin/validate-plugin-version.sh @@ -48,6 +48,12 @@ main() { CURRENT_WP_VERSION=$(curl -s https://api.wordpress.org/core/version-check/1.7/ | jq -r '.offers[0].current') echo "Current WordPress Version: ${CURRENT_WP_VERSION}" + # Adjust version based on validation level + if [[ "${VALIDATION_LEVEL:-minor}" == "minor" ]]; then + CURRENT_WP_VERSION=$(echo "$CURRENT_WP_VERSION" | cut -d'.' -f1,2) + echo "Validation level is 'minor', using WordPress version: ${CURRENT_WP_VERSION}" + fi + # Split FILENAMES into an array IFS=',' read -ra FILENAMES_ARRAY <<< "$FILENAMES" From eb3b9a10fe93f24c58a7dd76b8a6602ac4038246 Mon Sep 17 00:00:00 2001 From: Chris Reynolds Date: Thu, 30 Oct 2025 15:38:39 -0600 Subject: [PATCH 2/5] enhance version validation logic to support 'patch' level --- bin/validate-plugin-version.sh | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/bin/validate-plugin-version.sh b/bin/validate-plugin-version.sh index 107a191..a129d9f 100644 --- a/bin/validate-plugin-version.sh +++ b/bin/validate-plugin-version.sh @@ -49,10 +49,19 @@ main() { echo "Current WordPress Version: ${CURRENT_WP_VERSION}" # Adjust version based on validation level - if [[ "${VALIDATION_LEVEL:-minor}" == "minor" ]]; then - CURRENT_WP_VERSION=$(echo "$CURRENT_WP_VERSION" | cut -d'.' -f1,2) - echo "Validation level is 'minor', using WordPress version: ${CURRENT_WP_VERSION}" - fi + case "${VALIDATION_LEVEL:-minor}" in + minor) + CURRENT_WP_VERSION=$(echo "$CURRENT_WP_VERSION" | cut -d'.' -f1,2) + echo "Validation level is 'minor', using WordPress version: ${CURRENT_WP_VERSION}" + ;; + patch) + echo "Validation level is 'patch', using full WordPress version: ${CURRENT_WP_VERSION}" + ;; + *) + echo "Error: Invalid validation-level specified: ${VALIDATION_LEVEL}. Must be 'minor' or 'patch'." + exit 1 + ;; + esac # Split FILENAMES into an array IFS=',' read -ra FILENAMES_ARRAY <<< "$FILENAMES" From 8341ca2879934ef9a7dfebce86c310900764490a Mon Sep 17 00:00:00 2001 From: Chris Reynolds Date: Thu, 30 Oct 2025 15:39:46 -0600 Subject: [PATCH 3/5] docs: update validation-level section in README.md for clarity --- README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/README.md b/README.md index dcb6e0c..3ee56ca 100644 --- a/README.md +++ b/README.md @@ -57,6 +57,9 @@ The status to set on the PR. If not specified, the action will create a _draft_ #### `validation-level` The validation level to use. Accepts `patch` or `minor`. If not specified, the action will use `minor`. +- `minor`: Compares the "Tested Up To" version against the current WordPress version using only the major and minor numbers (e.g., `6.1`), ignoring the patch number. +- `patch`: Compares the full version including the patch number (e.g., `6.1.2`), requiring an exact match for validation. + ## Permissions 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. From d8953e3f675bc85a2db1b48765cce5cbe259a697 Mon Sep 17 00:00:00 2001 From: Chris Reynolds Date: Thu, 30 Oct 2025 15:41:29 -0600 Subject: [PATCH 4/5] test both minor and patch validation levels --- .github/workflows/test.yml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 3f48e31..6705aa2 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -3,6 +3,10 @@ on: [push, pull_request] jobs: test: runs-on: ubuntu-latest + strategy: + matrix: + validation-level: [minor, patch] + name: Test Validation Level ${{ matrix.validation-level }} steps: - uses: actions/checkout@v5 with: @@ -11,4 +15,5 @@ jobs: uses: ./ with: plugin-path: '.github/workflows/fixtures/plugin-test/' - dry-run: true \ No newline at end of file + dry-run: true + validation-level: ${{ matrix.validation-level }} \ No newline at end of file From 12976f6f40ac2053405ff0a2488950a3cdbb9556 Mon Sep 17 00:00:00 2001 From: Chris Reynolds Date: Thu, 30 Oct 2025 15:46:59 -0600 Subject: [PATCH 5/5] add more tests --- .../README.md | 0 .../plugin-test.php | 0 .../plugin-test-minor-fail/readme.txt | 10 ++++++++ .../fixtures/plugin-test-minor-pass/README.md | 10 ++++++++ .../plugin-test-minor-pass/plugin-test.php | 12 ++++++++++ .../plugin-test-minor-pass/readme.txt | 10 ++++++++ .../fixtures/plugin-test-patch-fail/README.md | 10 ++++++++ .../plugin-test-patch-fail/plugin-test.php | 12 ++++++++++ .../readme.txt | 0 .github/workflows/test.yml | 23 +++++++++++++------ 10 files changed, 80 insertions(+), 7 deletions(-) rename .github/workflows/fixtures/{plugin-test => plugin-test-minor-fail}/README.md (100%) rename .github/workflows/fixtures/{plugin-test => plugin-test-minor-fail}/plugin-test.php (100%) create mode 100644 .github/workflows/fixtures/plugin-test-minor-fail/readme.txt create mode 100644 .github/workflows/fixtures/plugin-test-minor-pass/README.md create mode 100644 .github/workflows/fixtures/plugin-test-minor-pass/plugin-test.php create mode 100644 .github/workflows/fixtures/plugin-test-minor-pass/readme.txt create mode 100644 .github/workflows/fixtures/plugin-test-patch-fail/README.md create mode 100644 .github/workflows/fixtures/plugin-test-patch-fail/plugin-test.php rename .github/workflows/fixtures/{plugin-test => plugin-test-patch-fail}/readme.txt (100%) diff --git a/.github/workflows/fixtures/plugin-test/README.md b/.github/workflows/fixtures/plugin-test-minor-fail/README.md similarity index 100% rename from .github/workflows/fixtures/plugin-test/README.md rename to .github/workflows/fixtures/plugin-test-minor-fail/README.md diff --git a/.github/workflows/fixtures/plugin-test/plugin-test.php b/.github/workflows/fixtures/plugin-test-minor-fail/plugin-test.php similarity index 100% rename from .github/workflows/fixtures/plugin-test/plugin-test.php rename to .github/workflows/fixtures/plugin-test-minor-fail/plugin-test.php diff --git a/.github/workflows/fixtures/plugin-test-minor-fail/readme.txt b/.github/workflows/fixtures/plugin-test-minor-fail/readme.txt new file mode 100644 index 0000000..a60f3a4 --- /dev/null +++ b/.github/workflows/fixtures/plugin-test-minor-fail/readme.txt @@ -0,0 +1,10 @@ +=== Plugin Test === +Contributors: jazzsequence +Tags: github actions, testing +Requires at least: 5.8 +Tested up to: 6.6 +Stable tag: 1.0.0 +License: MIT +License URI: https://opensource.org/licenses/MIT + +This is a test plugin for testing GitHub Actions workflows. \ No newline at end of file diff --git a/.github/workflows/fixtures/plugin-test-minor-pass/README.md b/.github/workflows/fixtures/plugin-test-minor-pass/README.md new file mode 100644 index 0000000..961e53c --- /dev/null +++ b/.github/workflows/fixtures/plugin-test-minor-pass/README.md @@ -0,0 +1,10 @@ +# Plugin Test +Contributors: jazzsequence +Tags: github actions, testing +Requires at least: 5.8 +Tested up to: 6.6.1 +Stable tag: 1.0.0 +License: MIT +License URI: https://opensource.org/licenses/MIT + +This is a test plugin for testing GitHub Actions workflows. \ No newline at end of file diff --git a/.github/workflows/fixtures/plugin-test-minor-pass/plugin-test.php b/.github/workflows/fixtures/plugin-test-minor-pass/plugin-test.php new file mode 100644 index 0000000..ff32419 --- /dev/null +++ b/.github/workflows/fixtures/plugin-test-minor-pass/plugin-test.php @@ -0,0 +1,12 @@ +