diff --git a/.github/scripts/sync-readme.sh b/.github/scripts/sync-readme.sh new file mode 100644 index 0000000..70ab229 --- /dev/null +++ b/.github/scripts/sync-readme.sh @@ -0,0 +1,49 @@ +#!/usr/bin/env bash +set -euo pipefail + +# Only update an existing release; never create or switch the stable tag. +read_stable_tag() { + sed -nE 's/^[Ss][Tt][Aa][Bb][Ll][Ee] [Tt][Aa][Gg]:[[:space:]]*([^[:space:]]+)[[:space:]]*$/\1/p' "$1" +} + +stable_tag=$(read_stable_tag readme.txt) +if [[ ! "$stable_tag" =~ ^[0-9]+(\.[0-9]+)*$ ]]; then + echo 'Expected one numeric Stable Tag in readme.txt.' >&2 + exit 1 +fi + +svn_url='https://plugins.svn.wordpress.org/aaa-option-optimizer' +svn_dir=$(mktemp -d) +trap 'rm -rf "$svn_dir"' EXIT + +svn checkout --non-interactive --depth empty "$svn_url" "$svn_dir" +svn update --non-interactive --depth empty "$svn_dir/trunk" "$svn_dir/tags" +svn update --non-interactive --depth empty "$svn_dir/tags/$stable_tag" +svn update --non-interactive "$svn_dir/trunk/readme.txt" "$svn_dir/tags/$stable_tag/readme.txt" + +for target in "$svn_dir/trunk/readme.txt" "$svn_dir/tags/$stable_tag/readme.txt"; do + if [[ ! -f "$target" ]] || [[ "$(read_stable_tag "$target")" != "$stable_tag" ]]; then + echo 'The local Stable Tag must match the published trunk and tag readmes.' >&2 + exit 1 + fi +done + +cp readme.txt "$svn_dir/trunk/readme.txt" +cp readme.txt "$svn_dir/tags/$stable_tag/readme.txt" + +if [[ -z "$(svn status "$svn_dir")" ]]; then + echo 'Both published readmes are already up to date.' + exit 0 +fi + +svn diff "$svn_dir" +if [[ "${DRY_RUN:-false}" == 'true' ]]; then + echo 'Dry run: no files were committed.' + exit 0 +fi + +: "${SVN_USERNAME:?SVN_USERNAME is required}" +: "${SVN_PASSWORD:?SVN_PASSWORD is required}" +svn_auth=(--username "$SVN_USERNAME" --password "$SVN_PASSWORD" --non-interactive --no-auth-cache) +svn commit "$svn_dir/trunk/readme.txt" "$svn_dir/tags/$stable_tag/readme.txt" \ + --message "Update aaa-option-optimizer readme.txt for $stable_tag" "${svn_auth[@]}" diff --git a/.github/workflows/readme-preview.yml b/.github/workflows/readme-preview.yml new file mode 100644 index 0000000..afca4a9 --- /dev/null +++ b/.github/workflows/readme-preview.yml @@ -0,0 +1,29 @@ +name: Plugin readme preview + +on: + pull_request_target: + types: [opened, synchronize, reopened, ready_for_review] + paths: + - "**/readme.txt" + - "**/README.txt" + - "**/readme.md" + - "**/README.md" + - "**/*.php" + - "**/.wordpress-org/**" + - "**/assets/**" + +permissions: + contents: read + pull-requests: write + +concurrency: + group: readme-preview-${{ github.event.pull_request.number }} + cancel-in-progress: true + +jobs: + preview: + if: github.event.repository.private == false + runs-on: ubuntu-24.04 + steps: + # No checkout or execution of pull-request code. The action reads files as data. + - uses: jdevalk/plugin-page-preview@3b44ebfe0eeecfcd46a1cce923b12fd5182c4320 # v1 diff --git a/.github/workflows/readme-sync.yml b/.github/workflows/readme-sync.yml new file mode 100644 index 0000000..379b0c0 --- /dev/null +++ b/.github/workflows/readme-sync.yml @@ -0,0 +1,33 @@ +name: Sync readme.txt to WordPress.org + +# The plugin directory reads metadata from the stable tag's readme. +# Update trunk and that tag together without publishing plugin code. +on: + workflow_dispatch: + +permissions: + contents: read + +concurrency: + group: wordpress-org-aaa-option-optimizer + cancel-in-progress: false + +jobs: + sync-readme: + name: Sync readme.txt to SVN trunk and stable tag + if: github.ref == 'refs/heads/main' + runs-on: ubuntu-latest + steps: + - name: Check out code + uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + persist-credentials: false + + - name: Install Subversion + run: sudo apt-get update && sudo apt-get install -y subversion + + - name: Sync published readmes + env: + SVN_USERNAME: ${{ secrets.SVN_USERNAME }} + SVN_PASSWORD: ${{ secrets.SVN_PASSWORD }} + run: bash .github/scripts/sync-readme.sh diff --git a/aaa-option-optimizer.php b/aaa-option-optimizer.php index 662be86..4015973 100644 --- a/aaa-option-optimizer.php +++ b/aaa-option-optimizer.php @@ -8,6 +8,8 @@ * Plugin URI: https://progressplanner.com/plugins/aaa-option-optimizer/ * Description: Tracks autoloaded options usage and allows the user to optimize them. * Version: 1.7.1 + * Requires at least: 6.7 + * Requires PHP: 7.4 * License: GPL-3.0+ * Author: Team Progress Planner * Author URI: https://progressplanner.com/ diff --git a/readme.txt b/readme.txt index 8a5dcbb..18fe0ca 100644 --- a/readme.txt +++ b/readme.txt @@ -2,7 +2,7 @@ Contributors: joostdevalk, aristath, filipi, progressplanner Tags: autoload, options, database, performance, cleanup Requires at least: 6.7 -Tested up to: 7.1 +Tested up to: 7.2 Stable tag: 1.7.1 Requires PHP: 7.4 License: GPL-3.0-or-later @@ -24,7 +24,7 @@ or turn off autoloading. == How It Works == -1. Install the plugin and browse your site normally for a few days. +1. Install and activate the plugin, then browse your site normally for a few days. 2. The plugin quietly records which autoloaded options are actually used during page rendering. 3. Visit the settings screen to see every autoloaded option that was