From 55cf65a08f3a0494b9bf95aa20f593bc1afd593e Mon Sep 17 00:00:00 2001 From: tijmen Date: Thu, 29 Jan 2026 10:31:54 +0100 Subject: [PATCH 1/4] Add version verification --- .github/workflows/release.yml | 2 ++ bin/check-version | 18 ++++++++++++++++++ 2 files changed, 20 insertions(+) create mode 100755 bin/check-version diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 232c6a2..48c2167 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -17,6 +17,8 @@ jobs: uses: actions/checkout@v4 with: fetch-depth: 0 + - name: Verify version matches release tag + run: bin/check-version - name: WordPress Plugin Deploy id: deploy uses: tinify/action-wordpress-plugin-deploy@stable diff --git a/bin/check-version b/bin/check-version new file mode 100755 index 0000000..23f0efa --- /dev/null +++ b/bin/check-version @@ -0,0 +1,18 @@ +#!/bin/bash +set -e + +# Script assumes release tags are formatted as MAJOR.MINOR.PATCH + +# https://docs.github.com/en/actions/reference/workflows-and-actions/variables +# For workflows triggered by release, this is the release tag created. +TAG_VERSION="${1:-${GITHUB_REF#refs/tags/}}" + +# Stable tag from readme.txt +README_VERSION=$(grep -m 1 "^Stable tag:" readme.txt | awk '{print $3}') + +if [ "$TAG_VERSION" != "$README_VERSION" ]; then + echo "Error: Tag: $TAG_VERSION, readme.txt: $README_VERSION" + exit 1 +fi + +echo "Version matches git release" From 3ba77ec4d06370d273b2f78ed2989884acad491e Mon Sep 17 00:00:00 2001 From: tijmen Date: Thu, 29 Jan 2026 10:32:08 +0100 Subject: [PATCH 2/4] Ensure plugin header file is in sync --- tiny-compress-images.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tiny-compress-images.php b/tiny-compress-images.php index 95f8514..2e56b0c 100644 --- a/tiny-compress-images.php +++ b/tiny-compress-images.php @@ -2,7 +2,7 @@ /** * Plugin Name: TinyPNG - JPEG, PNG & WebP image compression * Description: Speed up your website. Optimize your JPEG, PNG, and WebP images automatically with TinyPNG. - * Version: 3.6.7 + * Version: 3.6.8 * Author: TinyPNG * Author URI: https://tinypng.com * Text Domain: tiny-compress-images From 4c5779214109d58be1fb61e81f933cf92f0211b1 Mon Sep 17 00:00:00 2001 From: tijmen Date: Thu, 29 Jan 2026 10:32:18 +0100 Subject: [PATCH 3/4] Add test to verify plugin file with readme.txt --- test/unit/TinyVersionTest.php | 65 +++++++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) create mode 100644 test/unit/TinyVersionTest.php diff --git a/test/unit/TinyVersionTest.php b/test/unit/TinyVersionTest.php new file mode 100644 index 0000000..4b9be29 --- /dev/null +++ b/test/unit/TinyVersionTest.php @@ -0,0 +1,65 @@ +plugin_root = dirname(dirname(__DIR__)); + } + + /** + * Test that the version in readme.txt matches the version in tiny-compress-images.php. + */ + public function test_readme_version_matches_plugin_version() + { + $plugin_file = $this->plugin_root . '/tiny-compress-images.php'; + $readme_file = $this->plugin_root . '/readme.txt'; + + $plugin_version = $this->get_version($plugin_file, '/Version:\s*(.+)/'); + $readme_version = $this->get_version($readme_file, '/Stable tag:\s*(.+)/'); + + $this->assertEquals( + $readme_version, + $plugin_version, + sprintf( + 'readme.txt has %s but tiny-compress-images.php has version %s', + $readme_version, + $plugin_version + ) + ); + } + + + /** + * Extract version number from a plugin file. + * + * @param string $file_path Path to the file + * @return string|null The version number or null if not found. + */ + private function get_version($file_path, $regex) + { + $content = file_get_contents($file_path); + + if (preg_match($regex, $content, $matches)) { + return trim($matches[1]); + } + + return null; + } +} From 5aa556ba135c940feed59a14824ddf02a58912e5 Mon Sep 17 00:00:00 2001 From: tijmen Date: Thu, 29 Jan 2026 10:39:28 +0100 Subject: [PATCH 4/4] Explicit ignore for wordpress-org --- .distignore | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.distignore b/.distignore index 488ac6d..8c6a8ec 100644 --- a/.distignore +++ b/.distignore @@ -27,6 +27,7 @@ bin .github .wp-env.json .distignore +/.wordpress-org # editor/os -.vscode +.vscode \ No newline at end of file