diff --git a/.github/workflows/wordpress-org-plugin-page.yml b/.github/workflows/wordpress-org-plugin-page.yml new file mode 100644 index 00000000..35cb5e46 --- /dev/null +++ b/.github/workflows/wordpress-org-plugin-page.yml @@ -0,0 +1,825 @@ +# yaml-language-server: $schema=https://json.schemastore.org/github-workflow.json + +name: wordpress.org plugin page + +on: + workflow_call: + inputs: + SVN_PLUGIN_SLUG: + description: "WordPress.org plugin slug (e.g., 'woocommerce')" + type: string + required: true + + GIT_REF: + description: "Git ref to read readme.txt and the assets directory from (tag, branch, or full commit SHA)" + type: string + required: true + + SYNC_README: + description: "Update readme.txt in SVN trunk and in the tag referenced by 'Stable tag'" + type: boolean + default: true + required: false + + SYNC_ASSETS: + description: "Mirror ASSETS_DIR to the SVN /assets directory (banners, icons, screenshots, blueprints)" + type: boolean + default: true + required: false + + ASSETS_DIR: + description: "Directory in the Git repository holding the WordPress.org assets" + type: string + default: ".wordpress-org" + required: false + + DRY_RUN: + description: "Upload the files that would be committed as an artifact instead of committing to SVN" + type: boolean + default: true + required: false + + secrets: + SVN_USERNAME: + required: true + + SVN_PASSWORD: + required: true + +jobs: + update_plugin_page: + runs-on: ubuntu-latest + timeout-minutes: 10 + permissions: + contents: read + env: + # Filename rules of the WordPress.org plugin directory importer, restricted to the documented + # banner and icon resolutions. Shared by the asset validation and the scope guard, so they can't drift apart. + # The importer matches banners, icons, and screenshots case-insensitively, so these three are + # matched against the lowercased name. Blueprints are matched case-sensitively, like the importer does. + # Locale suffix: (-rtl)?(-[a-z]{2,3}(_[a-z]{2})?(_[a-z0-9]+)?)? + BANNER_RE: '^banner-(772x250|1544x500)(-rtl)?(-[a-z]{2,3}(_[a-z]{2})?(_[a-z0-9]+)?)?\.(png|jpg|jpeg|gif)$' + ICON_RE: '^icon-(128x128|256x256)(-rtl)?(-[a-z]{2,3}(_[a-z]{2})?(_[a-z0-9]+)?)?\.(png|jpg|jpeg|gif)$' + SCREENSHOT_RE: '^screenshot-[0-9]+(-rtl)?(-[a-z]{2,3}(_[a-z]{2})?(_[a-z0-9]+)?)?\.(png|jpg|jpeg|gif)$' + BLUEPRINT_RE: '^blueprints/blueprint[-A-Za-z0-9_]*\.json$' + # Prints the value of every readme.txt header line with the given key, one per line. Only lines before the + # first == Section == count. The key is case-insensitive, and spaces, "*" and "-" around key and value are ignored. + # Callers decide what zero or several matches mean, so an ambiguous readme fails instead of guessing + # which value WordPress.org would use. Usage: awk -v key="stable tag" "$README_HEADER_AWK" readme.txt + README_HEADER_AWK: | + { sub(/\r$/, "") } + /^==[^=]/ { exit } + index($0, ":") { + k = tolower(substr($0, 1, index($0, ":") - 1)) + v = substr($0, index($0, ":") + 1) + gsub(/^[ \t*-]+|[ \t*-]+$/, "", k) + gsub(/^[ \t*-]+|[ \t*-]+$/, "", v) + if (k == tolower(key)) print v + } + steps: + - name: Install required tools + env: + SYNC_ASSETS: ${{ inputs.SYNC_ASSETS }} + run: | + set -euo pipefail + + PACKAGES=(subversion) + + # Only the asset validation and sync need these. + if [ "$SYNC_ASSETS" = "true" ]; then + PACKAGES+=(rsync jq imagemagick) + fi + + sudo apt-get update -y + sudo apt-get install -y "${PACKAGES[@]}" + + - name: Validate inputs + env: + SVN_PLUGIN_SLUG: ${{ inputs.SVN_PLUGIN_SLUG }} + GIT_REF: ${{ inputs.GIT_REF }} + SYNC_README: ${{ inputs.SYNC_README }} + SYNC_ASSETS: ${{ inputs.SYNC_ASSETS }} + ASSETS_DIR: ${{ inputs.ASSETS_DIR }} + run: | + set -euo pipefail + + if [[ ! "$SVN_PLUGIN_SLUG" =~ ^[a-z0-9-]+$ ]]; then + echo "❌ Invalid plugin slug: $SVN_PLUGIN_SLUG" + echo " WordPress.org slugs may only contain lowercase letters, numbers, and hyphens" + exit 1 + fi + + echo "✅ Valid plugin slug: $SVN_PLUGIN_SLUG" + + if ! git check-ref-format --allow-onelevel "$GIT_REF"; then + echo "❌ Invalid Git ref name: $GIT_REF" + exit 1 + fi + + if [ "$SYNC_README" != "true" ] && [ "$SYNC_ASSETS" != "true" ]; then + echo "❌ Nothing to do: both SYNC_README and SYNC_ASSETS are disabled" + exit 1 + fi + + # ASSETS_DIR is used as an rsync source, so keep it inside the repository. + # Symlinks can only be checked after the checkout, see "Validate assets directory". + if [[ ! "$ASSETS_DIR" =~ ^[A-Za-z0-9._-]+(/[A-Za-z0-9._-]+)*$ ]] || [[ "/$ASSETS_DIR/" == *"/../"* ]]; then + echo "❌ Invalid ASSETS_DIR: $ASSETS_DIR" + echo " Must be a relative path inside the repository, without '..' segments" + exit 1 + fi + + echo "✅ Inputs are valid" + + # GIT_REF is validated above, so it is safe to pass it to actions/checkout directly. + - name: Checkout git repository + uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4.4.0 + with: + ref: ${{ inputs.GIT_REF }} + persist-credentials: false + + - name: Resolve Git revision + id: git_revision + run: | + set -euo pipefail + echo "SHORT_SHA=$(git rev-parse --short HEAD)" >> "$GITHUB_OUTPUT" + + - name: Validate readme.txt + id: readme + if: inputs.SYNC_README == true + run: | + set -euo pipefail + + # A symlink could point anywhere on the runner, and the file it points to would be published. + # wordpress-org-release skips symlinks too, so a symlinked readme.txt would never be released. + if [ -L readme.txt ]; then + echo "❌ readme.txt must be a regular file, not a symlink" + exit 1 + fi + + if [ ! -f readme.txt ]; then + echo "❌ readme.txt not found" + exit 1 + fi + + # The Stable tag decides which SVN tag gets the readme, so anything ambiguous fails. + mapfile -t STABLE_TAGS < <(awk -v key="stable tag" "$README_HEADER_AWK" readme.txt) + if [ "${#STABLE_TAGS[@]}" -ne 1 ]; then + echo "❌ readme.txt must have exactly one 'Stable tag:' line before the first == Section ==, found ${#STABLE_TAGS[@]}" + exit 1 + fi + STABLE_TAG="${STABLE_TAGS[0]}" + + if [ -z "$STABLE_TAG" ]; then + echo "❌ 'Stable tag:' in readme.txt is empty" + exit 1 + fi + + if [ "$STABLE_TAG" = "trunk" ]; then + echo "❌ 'Stable tag: trunk' is not supported (and discouraged by WordPress.org)" + exit 1 + fi + + # This workflow never creates versions, it only has to find the existing tag, so it accepts + # the same characters WordPress.org allows in a Stable tag (e.g. 1.2.3.4, 1.0.0-rc1, v1.2). + # This intentionally differs from the strict X.Y.Z check of wordpress-org-release, which creates new tags. + # The value is used in SVN paths, so '..' is rejected; the tag's existence is verified against SVN later. + if [[ ! "$STABLE_TAG" =~ ^[A-Za-z0-9][A-Za-z0-9_.-]*$ ]] || [[ "$STABLE_TAG" == *..* ]]; then + echo "❌ Unexpected 'Stable tag' format in readme.txt: $STABLE_TAG" + exit 1 + fi + + echo "STABLE_TAG=$STABLE_TAG" >> "$GITHUB_OUTPUT" + echo "✅ readme.txt found, Stable tag: $STABLE_TAG" + + - name: Validate assets directory + if: inputs.SYNC_ASSETS == true + env: + ASSETS_DIR: ${{ inputs.ASSETS_DIR }} + run: | + set -euo pipefail + + if [ ! -d "$ASSETS_DIR" ]; then + echo "❌ Assets directory not found: $ASSETS_DIR" + exit 1 + fi + + # The input check only rejects '..'. ASSETS_DIR or one of its parents could still be a symlink + # that points outside the repository, and rsync would publish whatever is there. + REAL_ASSETS_DIR=$(realpath -e "$ASSETS_DIR") + REAL_WORKSPACE=$(realpath -e "$GITHUB_WORKSPACE") + if [[ "$REAL_ASSETS_DIR/" != "$REAL_WORKSPACE/"* ]]; then + echo "❌ Assets directory resolves to a path outside the repository: $ASSETS_DIR -> $REAL_ASSETS_DIR" + exit 1 + fi + + ERRORS=0 + + # Symlinks would be skipped by rsync and silently leave the old file in SVN, + # and any directory other than blueprints/ would be committed as is. + mapfile -t UNSUPPORTED < <(cd "$ASSETS_DIR" && find . -mindepth 1 ! -path '*/.*' \ + \( ! -type f ! -type d -o -type d ! -path ./blueprints \) -printf '%P\n' | LC_ALL=C sort) + + for ENTRY in "${UNSUPPORTED[@]}"; do + if [ -d "$ASSETS_DIR/$ENTRY" ] && [ ! -L "$ASSETS_DIR/$ENTRY" ]; then + echo "❌ $ENTRY/ is not supported, only the blueprints/ subdirectory is allowed" + else + echo "❌ $ENTRY is not a regular file (symlinks are not supported)" + fi + ERRORS=1 + done + + # Hidden files (.gitkeep, .DS_Store, ...) are ignored here and by the sync below. + mapfile -t FILES < <(cd "$ASSETS_DIR" && find . -type f ! -path '*/.*' -printf '%P\n' | LC_ALL=C sort) + + # The sync mirrors this directory, so an empty directory would wipe the plugin page. + if [ "${#FILES[@]}" -eq 0 ]; then + echo "❌ Assets directory is empty: $ASSETS_DIR" + echo " Syncing it would delete every asset from WordPress.org. Aborting." + exit 1 + fi + + HAS_RASTER_ICON=0 + HAS_SVG_ICON=0 + BLUEPRINT_COUNT=0 + declare -A SEEN_NAMES=() + + for FILE in "${FILES[@]}"; do + SIZE=$(stat -c %s "$ASSETS_DIR/$FILE") + LOWER="${FILE,,}" + # Banners and raster icons must have the dimensions their name says, + # WordPress.org trusts the name and would render a different size distorted. + EXPECTED_DIMENSIONS="" + + # The importer ignores case, so two names differing only in case would be the same asset. + if [ -n "${SEEN_NAMES[$LOWER]:-}" ]; then + echo "❌ $FILE and ${SEEN_NAMES[$LOWER]} differ only in case" + ERRORS=1 + continue + fi + SEEN_NAMES[$LOWER]="$FILE" + + if [[ "$LOWER" =~ $BANNER_RE ]]; then + LIMIT=$((4 * 1024 * 1024)) + EXPECTED_DIMENSIONS="${BASH_REMATCH[1]}" + elif [[ "$LOWER" =~ $ICON_RE ]]; then + LIMIT=$((1 * 1024 * 1024)) + EXPECTED_DIMENSIONS="${BASH_REMATCH[1]}" + HAS_RASTER_ICON=1 + elif [ "$FILE" = "icon.svg" ]; then + LIMIT=$((1 * 1024 * 1024)) + HAS_SVG_ICON=1 + elif [[ "$LOWER" =~ $SCREENSHOT_RE ]]; then + LIMIT=$((10 * 1024 * 1024)) + elif [[ "$FILE" =~ $BLUEPRINT_RE ]]; then + LIMIT=$((100 * 1024)) + BLUEPRINT_COUNT=$((BLUEPRINT_COUNT + 1)) + # The importer requires a JSON object or array, scalars are rejected. + if ! jq -e 'type == "object" or type == "array"' "$ASSETS_DIR/$FILE" >/dev/null 2>&1; then + echo "❌ $FILE is not a valid JSON object or array" + ERRORS=1 + fi + else + # The importer accepts any case for .svg, but the plugin page only displays icon.svg. + if [ "$LOWER" = "icon.svg" ]; then + echo "❌ $FILE must be named exactly icon.svg (WordPress.org only displays icon.svg)" + else + echo "❌ $FILE is not a recognized WordPress.org asset (WordPress.org would ignore it)" + fi + ERRORS=1 + continue + fi + + if [ "$SIZE" -eq 0 ]; then + echo "❌ $FILE is empty" + ERRORS=1 + continue + elif [ "$SIZE" -gt "$LIMIT" ]; then + echo "❌ $FILE is $SIZE bytes, WordPress.org limit is $LIMIT bytes" + ERRORS=1 + fi + + # The real format must match the extension. This also catches Git LFS pointer files, + # which actions/checkout fetches instead of the images unless LFS is enabled. + case "$LOWER" in + *.png) EXPECTED_FORMAT="PNG" ;; + *.jpg|*.jpeg) EXPECTED_FORMAT="JPEG" ;; + *.gif) EXPECTED_FORMAT="GIF" ;; + *.svg) + if ! grep -qi '/dev/null || true) + if [ "$FORMAT" != "$EXPECTED_FORMAT" ]; then + echo "❌ $FILE is ${FORMAT:-not a readable image} (expected $EXPECTED_FORMAT). Git LFS files are not supported" + ERRORS=1 + continue + fi + + if [ -n "$EXPECTED_DIMENSIONS" ]; then + DIMENSIONS=$(identify -ping -format '%wx%h' "$ASSETS_DIR/${FILE}[0]" 2>/dev/null || true) + if [ "$DIMENSIONS" != "$EXPECTED_DIMENSIONS" ]; then + echo "❌ $FILE is ${DIMENSIONS:-unreadable}, expected $EXPECTED_DIMENSIONS" + ERRORS=1 + fi + fi + done + + # WordPress.org would show icon.svg alone, but its Plugin Assets docs recommend a raster fallback. + if [ "$HAS_SVG_ICON" = "1" ] && [ "$HAS_RASTER_ICON" = "0" ]; then + echo "❌ icon.svg requires a PNG/JPG/GIF icon (icon-128x128 or icon-256x256) as fallback (required by this workflow)" + ERRORS=1 + fi + + # WordPress.org would import only the first 10 and skip the rest. + if [ "$BLUEPRINT_COUNT" -gt 10 ]; then + echo "❌ $BLUEPRINT_COUNT blueprints found, at most 10 are allowed (required by this workflow, WordPress.org imports only 10)" + ERRORS=1 + fi + + [ "$ERRORS" = "1" ] && exit 1 + + echo "✅ ${#FILES[@]} asset(s) in $ASSETS_DIR are valid" + + - name: Checkout SVN repository + env: + SVN_PLUGIN_SLUG: ${{ inputs.SVN_PLUGIN_SLUG }} + SYNC_README: ${{ inputs.SYNC_README }} + SYNC_ASSETS: ${{ inputs.SYNC_ASSETS }} + STABLE_TAG: ${{ steps.readme.outputs.STABLE_TAG }} + run: | + set -euo pipefail + + export SVN_REPO_ROOT="${RUNNER_TEMP}/svn_repository/${SVN_PLUGIN_SLUG}" + echo "SVN_REPO_ROOT=$SVN_REPO_ROOT" >> "$GITHUB_ENV" + + # Sparse checkout: only the files this workflow may change are fetched. + # trunk and tags stay (nearly) empty, which keeps this fast for plugins with large histories. + mkdir -p "$(dirname "$SVN_REPO_ROOT")" + svn checkout "https://plugins.svn.wordpress.org/${SVN_PLUGIN_SLUG}" "$SVN_REPO_ROOT" --depth immediates + cd "$SVN_REPO_ROOT" + + if [ "$SYNC_README" = "true" ]; then + svn update trunk/readme.txt + svn update tags --set-depth immediates + + if [ -d "tags/$STABLE_TAG" ]; then + svn update "tags/$STABLE_TAG/readme.txt" + fi + fi + + if [ "$SYNC_ASSETS" = "true" ]; then + if [ -d assets ]; then + svn update assets --set-depth infinity + else + echo "ℹ️ No /assets directory in SVN yet, creating it" + svn mkdir assets + fi + fi + + - name: Verify Stable tag matches WordPress.org + if: inputs.SYNC_README == true + env: + SVN_PLUGIN_SLUG: ${{ inputs.SVN_PLUGIN_SLUG }} + STABLE_TAG: ${{ steps.readme.outputs.STABLE_TAG }} + run: | + set -euo pipefail + + cd "$SVN_REPO_ROOT" + + if [ ! -f trunk/readme.txt ]; then + echo "❌ trunk/readme.txt does not exist in SVN" + exit 1 + fi + + mapfile -t SVN_STABLE_TAGS < <(awk -v key="stable tag" "$README_HEADER_AWK" trunk/readme.txt) + if [ "${#SVN_STABLE_TAGS[@]}" -ne 1 ]; then + echo "❌ trunk/readme.txt in SVN must have exactly one 'Stable tag:' line before the first == Section ==, found ${#SVN_STABLE_TAGS[@]}" + echo " Fix trunk/readme.txt in SVN first, e.g. with the next release." + exit 1 + fi + SVN_STABLE_TAG="${SVN_STABLE_TAGS[0]}" + + # Changing the Stable tag means publishing a different version - that is a release. + if [ "$STABLE_TAG" != "$SVN_STABLE_TAG" ]; then + echo "❌ readme.txt Stable tag ($STABLE_TAG) does not match Stable tag in SVN trunk ($SVN_STABLE_TAG)" + echo " This workflow cannot change the Stable tag. Use the wordpress-org-release workflow to publish a new version," + echo " or pass a GIT_REF whose readme.txt matches the currently published version." + exit 1 + fi + + if [ ! -f "tags/$STABLE_TAG/readme.txt" ]; then + echo "❌ tags/$STABLE_TAG/readme.txt does not exist in SVN" + echo " Check: https://plugins.svn.wordpress.org/${SVN_PLUGIN_SLUG}/tags/" + exit 1 + fi + + echo "✅ Stable tag $STABLE_TAG matches SVN trunk and exists as a published tag" + + - name: Synchronize readme.txt + if: inputs.SYNC_README == true + env: + STABLE_TAG: ${{ steps.readme.outputs.STABLE_TAG }} + run: | + set -euo pipefail + + cd "$SVN_REPO_ROOT" + GIT_README="$GITHUB_WORKSPACE/readme.txt" + TAG_README="tags/$STABLE_TAG/readme.txt" + + # Several matches are joined into one line: the value ends up in a ::warning, and a line break would let + # readme.txt start its own workflow command on the next line. + readme_header() { + awk -v key="$1" "$README_HEADER_AWK" "$2" | paste -sd ',' - + } + + # Unlike the rest of readme.txt, these headers aren't just displayed: unless the main plugin file + # declares them, WordPress.org publishes them as the version's requirements, and WordPress blocks + # installing or updating to that version on sites that don't meet them. + for HEADER in "Requires at least" "Requires PHP"; do + OLD_VALUE=$(readme_header "$HEADER" "$TAG_README") + NEW_VALUE=$(readme_header "$HEADER" "$GIT_README") + if [ "$OLD_VALUE" != "$NEW_VALUE" ]; then + echo "::warning title=$HEADER changed::'$HEADER' changes from '${OLD_VALUE:-(none)}' to '${NEW_VALUE:-(none)}' for the already published version $STABLE_TAG. Unless the main plugin file declares it, WordPress uses this value to block installs and updates on sites that don't meet it." + fi + done + + # If trunk's readme already differs from the published one, trunk holds unreleased changes + # (e.g. a trunk preview created by wordpress-org-release with UPDATE_TRUNK_ONLY). + # Overwriting it would silently revert those, so trunk is left alone in that case. + if cmp -s trunk/readme.txt "$TAG_README"; then + TRUNK_IN_SYNC=true + else + TRUNK_IN_SYNC=false + fi + + # WordPress.org treats any change to a released tag as a modified release, + # and with Release Confirmation enabled that release must be confirmed again. + if ! cmp -s "$GIT_README" "$TAG_README"; then + RC_MESSAGE="If this plugin has Release Confirmation enabled on WordPress.org, updating $TAG_README reopens release $STABLE_TAG for confirmation. All committers get an email, and the plugin page updates only after the release is confirmed again." + echo "::notice title=Release Confirmation::$RC_MESSAGE" + + # Notices are the easiest annotation to miss, so this is repeated in the job summary next to the SVN changes. + { + echo '### ℹ️ Release Confirmation' + echo "$RC_MESSAGE" + echo + } >> "$GITHUB_STEP_SUMMARY" + fi + + # The plugin page is rendered from the readme.txt of the Stable tag. + if cmp -s "$GIT_README" "$TAG_README"; then + echo "ℹ️ $TAG_README is already up to date" + else + cp "$GIT_README" "$TAG_README" + echo "✅ Updated $TAG_README" + fi + + if cmp -s trunk/readme.txt "$GIT_README"; then + echo "ℹ️ trunk/readme.txt is already up to date" + elif [ "$TRUNK_IN_SYNC" = "true" ]; then + cp "$GIT_README" trunk/readme.txt + echo "✅ Updated trunk/readme.txt" + else + echo "::warning title=trunk/readme.txt left unchanged::SVN trunk contains unreleased readme.txt changes (likely a trunk preview). Only $TAG_README was updated. Make sure the same change is part of the upcoming release." + + # Warnings are easy to miss, so this is repeated in the job summary next to the SVN changes. + { + echo '### ⚠️ trunk/readme.txt left unchanged' + echo "SVN trunk holds unreleased \`readme.txt\` changes (likely a trunk preview), so only \`$TAG_README\` is updated. Make sure the same change is in the next release." + echo + } >> "$GITHUB_STEP_SUMMARY" + fi + + - name: Synchronize assets + if: inputs.SYNC_ASSETS == true + env: + ASSETS_DIR: ${{ inputs.ASSETS_DIR }} + run: | + set -euo pipefail + + rsync -rc \ + --itemize-changes \ + --delete \ + --exclude='.*' \ + "$GITHUB_WORKSPACE/$ASSETS_DIR/" "$SVN_REPO_ROOT/assets/" + + cd "$SVN_REPO_ROOT" + svn add assets --force --depth infinity --quiet + + MISSING=$(svn status assets | grep '^!' | cut -c9- || true) + + if [ -n "$MISSING" ]; then + echo "$MISSING" | while IFS= read -r file; do + svn delete "$file@" # @ suffix handles files with @ in name + done + fi + + # Without a correct svn:mime-type, browsers may download images instead of displaying them when opened directly. + # 'svn add' marks binaries as application/octet-stream, so this also fixes newly added files. + # Blueprints get no svn:mime-type: SVN treats application/json as binary, which makes their diffs unreadable, + # and the server sends .json files as application/json anyway. Earlier runs set it, so it is removed here. + find assets -type f ! -path '*/.*' | while IFS= read -r file; do + case "${file,,}" in + *.png) MIME_TYPE="image/png" ;; + *.jpg|*.jpeg) MIME_TYPE="image/jpeg" ;; + *.gif) MIME_TYPE="image/gif" ;; + *.svg) MIME_TYPE="image/svg+xml" ;; + *.json) + if [ -n "$(svn propget svn:mime-type "$file@" 2>/dev/null || true)" ]; then + svn propdel --quiet svn:mime-type "$file@" + fi + continue + ;; + *) continue ;; + esac + + if [ "$(svn propget svn:mime-type "$file@" 2>/dev/null || true)" != "$MIME_TYPE" ]; then + svn propset --quiet svn:mime-type "$MIME_TYPE" "$file@" + fi + done + + - name: Verify the plugin page keeps its icon and banner + if: inputs.SYNC_ASSETS == true + env: + ASSETS_DIR: ${{ inputs.ASSETS_DIR }} + run: | + set -euo pipefail + + cd "$SVN_REPO_ROOT" + + # An incomplete assets directory would strip the plugin page, so removing the last icon or banner is refused. + mapfile -t DELETED < <(svn status assets | grep '^D' | cut -c9- | sed 's|^assets/||' || true) + mapfile -t REMAINING < <(cd assets && find . -type f ! -path '*/.*' -printf '%P\n') + + # Only default assets count: localized ones (-rtl, -de, ...) are shown just for those locales. + # The shared patterns also match localized names. Every locale suffix starts with "-", so a default + # name has exactly one "-" before the extension (icon-128x128.png, screenshot-1.png). + count_assets() { + local TYPE="$1" COUNT=0 NAME LOWER RE + shift + case "$TYPE" in + icon) RE="$ICON_RE" ;; + banner) RE="$BANNER_RE" ;; + screenshot) RE="$SCREENSHOT_RE" ;; + esac + for NAME in "$@"; do + LOWER="${NAME,,}" + if [[ ( "$LOWER" =~ $RE && "${LOWER%.*}" != *-*-* ) || ( "$TYPE" = "icon" && "$NAME" = "icon.svg" ) ]]; then + COUNT=$((COUNT + 1)) + fi + done + echo "$COUNT" + } + + removes_all() { + [ "$(count_assets "$1" "${DELETED[@]}")" -gt 0 ] && [ "$(count_assets "$1" "${REMAINING[@]}")" -eq 0 ] + } + + ERRORS=0 + for TYPE in icon banner; do + if removes_all "$TYPE"; then + echo "❌ This run would remove every $TYPE from the plugin page." + echo " Add a $TYPE to $ASSETS_DIR, or remove it by hand in SVN if that's really intended." + ERRORS=1 + fi + done + + if [ "$ERRORS" = "1" ]; then + exit 1 + fi + + # Removing all screenshots can be intended, but leaves the readme's screenshot captions without images. + if removes_all screenshot; then + echo "::warning title=All screenshots removed::This run removes every screenshot from the plugin page. Make sure the == Screenshots == section of readme.txt matches." + { + echo '### ⚠️ All screenshots removed' + echo "This run removes every screenshot from the plugin page. Make sure the \`== Screenshots ==\` section of \`readme.txt\` matches." + echo + } >> "$GITHUB_STEP_SUMMARY" + fi + + echo "✅ The plugin page keeps its icon and banner" + + - name: Verify only plugin page files are changed + env: + SYNC_README: ${{ inputs.SYNC_README }} + SYNC_ASSETS: ${{ inputs.SYNC_ASSETS }} + STABLE_TAG: ${{ steps.readme.outputs.STABLE_TAG }} + run: | + set -euo pipefail + + cd "$SVN_REPO_ROOT" + + # Defense in depth: whatever the steps above did, only files allowed by the enabled options get committed. + is_allowed() { + local STATUS="$1" FILE="$2" + + # The readmes may only be modified, never added or deleted. + if [ "$SYNC_README" = "true" ] && [ "$STATUS" = "M" ]; then + case "$FILE" in + trunk/readme.txt|"tags/$STABLE_TAG/readme.txt") return 0 ;; + esac + fi + + if [ "$SYNC_ASSETS" = "true" ]; then + case "$FILE" in + assets|assets/blueprints) return 0 ;; + assets/*) + # Mirroring deletes whatever isn't in Git, including legacy files with names WordPress.org + # ignores, so any file in /assets may be deleted. Added or modified files must be recognized assets. + [ "$STATUS" = "D" ] && return 0 + local ASSET="${FILE#assets/}" + [ "$ASSET" = "icon.svg" ] && return 0 + local LOWER="${ASSET,,}" + [[ "$LOWER" =~ $BANNER_RE || "$LOWER" =~ $ICON_RE || "$LOWER" =~ $SCREENSHOT_RE || "$ASSET" =~ $BLUEPRINT_RE ]] && return 0 + ;; + esac + fi + + return 1 + } + + UNEXPECTED=$(svn status | while IFS= read -r line; do + if ! is_allowed "${line:0:1}" "${line:8}"; then + echo "$line" + fi + done) + + if [ -n "$UNEXPECTED" ]; then + echo "❌ Unexpected changes outside of the plugin page files:" + echo "$UNEXPECTED" + exit 1 + fi + + echo "✅ Only plugin page files are changed" + + - name: Show SVN changes + id: svn_status + env: + DRY_RUN: ${{ inputs.DRY_RUN }} + SYNC_README: ${{ inputs.SYNC_README }} + SYNC_ASSETS: ${{ inputs.SYNC_ASSETS }} + STABLE_TAG: ${{ steps.readme.outputs.STABLE_TAG }} + run: | + set -euo pipefail + + cd "$SVN_REPO_ROOT" + + # The commit and the dry run preview share this list. + COMMIT_PATHS_FILE="${RUNNER_TEMP}/commit-paths.txt" + echo "COMMIT_PATHS_FILE=$COMMIT_PATHS_FILE" >> "$GITHUB_ENV" + : > "$COMMIT_PATHS_FILE" + README_PATHS=() + + if [ "$SYNC_README" = "true" ]; then + README_PATHS=(trunk/readme.txt "tags/$STABLE_TAG/readme.txt") + printf '%s\n' "${README_PATHS[@]}" >> "$COMMIT_PATHS_FILE" + fi + + if [ "$SYNC_ASSETS" = "true" ]; then + echo assets >> "$COMMIT_PATHS_FILE" + fi + + STATUS=$(svn status) + + # Content (first column) or property (second column) changes + if grep -E '^([ADMR~]|.M)' >/dev/null <<< "$STATUS"; then + echo "HAS_CHANGES=true" >> "$GITHUB_OUTPUT" + else + echo "HAS_CHANGES=false" >> "$GITHUB_OUTPUT" + echo "✅ The WordPress.org plugin page is already up to date, nothing to commit." | tee -a "$GITHUB_STEP_SUMMARY" + exit 0 + fi + + DELETED=$(grep '^D' <<< "$STATUS" | cut -c9- || true) + + README_DIFF="" + if [ "${#README_PATHS[@]}" -gt 0 ]; then + README_DIFF=$(svn diff "${README_PATHS[@]}") + fi + + # Readme files may contain ``` themselves, so a longer fence is used. + { + # Dry and live runs show the same changes, so the heading says whether they were committed. + if [ "$DRY_RUN" = "true" ]; then + echo '### SVN changes (dry run, nothing committed)' + else + echo '### SVN changes' + fi + echo '`````' + echo "$STATUS" + echo '`````' + + if [ -n "$DELETED" ]; then + echo '### ⚠️ Removed from WordPress.org' + echo '`````' + echo "$DELETED" + echo '`````' + fi + + # Readme diffs are text and worth reviewing; binary assets are listed by status only. + if [ -n "$README_DIFF" ]; then + echo '### readme.txt diff' + echo '`````diff' + echo "$README_DIFF" + echo '`````' + fi + } | tee -a "$GITHUB_STEP_SUMMARY" + + - name: Commit changes to SVN repository + if: inputs.DRY_RUN == false + env: + SVN_USERNAME: ${{ secrets.SVN_USERNAME }} + SVN_PASSWORD: ${{ secrets.SVN_PASSWORD }} + SVN_PLUGIN_SLUG: ${{ inputs.SVN_PLUGIN_SLUG }} + GIT_REF: ${{ inputs.GIT_REF }} + SHORT_SHA: ${{ steps.git_revision.outputs.SHORT_SHA }} + HAS_CHANGES: ${{ steps.svn_status.outputs.HAS_CHANGES }} + run: | + set -euo pipefail + + # Unlike a release, a run without changes is not an error: the plugin page is already up to date. + if [ "$HAS_CHANGES" != "true" ]; then + echo "::notice title=No changes::The WordPress.org plugin page is already up to date" + exit 0 + fi + + cd "$SVN_REPO_ROOT" + + mapfile -t COMMIT_PATHS < "$COMMIT_PATHS_FILE" + COMMIT_MESSAGE="Update plugin page from ${GIT_REF}@${SHORT_SHA}" + COMMIT_LOG="${RUNNER_TEMP}/svn-commit.log" + + # WordPress.org SVN doesn't support SSH keys or tokens. + # Keeping credentials as step-level env vars with --no-auth-cache is the best available option. + # The password is piped via stdin, so it never shows up in the process list (argv). + # printf must stay the bash builtin, and set -x must not be enabled in this step. + echo '🚀 Committing...' + + if ! printf '%s' "$SVN_PASSWORD" | svn commit "${COMMIT_PATHS[@]}" \ + --username "$SVN_USERNAME" \ + --password-from-stdin \ + --no-auth-cache \ + --non-interactive \ + -m "$COMMIT_MESSAGE" 2>&1 | tee "$COMMIT_LOG"; then + if grep -qE 'E160028|E160024|out of date' "$COMMIT_LOG"; then + echo "::error title=Concurrent SVN commit::Someone else committed to this plugin on WordPress.org in the meantime (maybe a release running at the same time). Nothing was changed. Re-run this workflow once the other run has finished." + elif grep -q 'E175012' "$COMMIT_LOG"; then + # The server can still be busy in "Committing transaction..." when svn's HTTP timeout runs out. + echo "::error title=SVN commit timed out::WordPress.org didn't confirm the commit in time, but it may still have gone through. Re-run this workflow: it either reports that the plugin page is already up to date or commits the changes." + fi + exit 1 + fi + + REVISION=$(grep -oP 'Committed revision \K[0-9]+' "$COMMIT_LOG" || true) + { + if [ -n "$REVISION" ]; then + echo "✅ Committed [r$REVISION](https://plugins.trac.wordpress.org/changeset/$REVISION) to WordPress.org." + else + echo "✅ Committed to WordPress.org." + fi + echo "The [plugin page](https://wordpress.org/plugins/$SVN_PLUGIN_SLUG/) may take a few minutes (up to hours) to show the changes due to CDN caching." + } | tee -a "$GITHUB_STEP_SUMMARY" + + - name: Prepare dry run preview + if: inputs.DRY_RUN == true && steps.svn_status.outputs.HAS_CHANGES == 'true' + run: | + set -euo pipefail + + PREVIEW_DIR="${RUNNER_TEMP}/plugin_page_preview" + echo "PREVIEW_DIR=$PREVIEW_DIR" >> "$GITHUB_ENV" + mkdir -p "$PREVIEW_DIR" + + cd "$SVN_REPO_ROOT" + + # The preview holds exactly what would be committed, in its final state: + # each path only if it changes (e.g. trunk is left alone when it holds unreleased changes). + while IFS= read -r COMMIT_PATH; do + if [ -z "$(svn status "$COMMIT_PATH")" ]; then + continue + fi + + if [ "$COMMIT_PATH" = "assets" ]; then + rsync -r --exclude='.svn' assets/ "$PREVIEW_DIR/assets/" + else + mkdir -p "$PREVIEW_DIR/$(dirname "$COMMIT_PATH")" + cp "$COMMIT_PATH" "$PREVIEW_DIR/$COMMIT_PATH" + fi + done < "$COMMIT_PATHS_FILE" + + - name: Upload dry run preview as an artifact + if: inputs.DRY_RUN == true && steps.svn_status.outputs.HAS_CHANGES == 'true' + uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2 + with: + name: ${{ inputs.SVN_PLUGIN_SLUG }}-plugin-page + path: ${{ env.PREVIEW_DIR }} + if-no-files-found: error + compression-level: 1 #Minimal compression - we don't want to waste resources for this diff --git a/README.md b/README.md index 37777018..e15f0067 100644 --- a/README.md +++ b/README.md @@ -42,6 +42,7 @@ groups here: * End-to-end tests with [Playwright](./docs/test-playwright.md) * [Build and distribute plugin and theme archives](./docs/build-and-distribute.md) * [Release to the WordPress.org plugin directory](./docs/wordpress-org-release.md) +* [Update the WordPress.org plugin page (readme and assets)](./docs/wordpress-org-plugin-page.md) * [Quality Insights Toolkit (QIT) for WooCommerce](./docs/woo-qit.md) * [Deployments with Deployer](./docs/deploy-deployer.md) diff --git a/docs/wordpress-org-plugin-page.md b/docs/wordpress-org-plugin-page.md new file mode 100644 index 00000000..92caaac0 --- /dev/null +++ b/docs/wordpress-org-plugin-page.md @@ -0,0 +1,300 @@ +# WordPress.org Plugin Page + +This reusable workflow updates what the [WordPress.org plugin directory](https://wordpress.org/plugins/) shows on a plugin's page (the `readme.txt` and the banners, icons, screenshots, and Playground blueprints) **without releasing a new plugin version**. + +Use it for changes like: + +- adding or removing promotional links in `readme.txt` +- bumping `Tested up to` after verifying compatibility with a new WordPress release +- fixing typos, FAQ entries, or screenshot captions +- temporarily swapping a banner (e.g. for a campaign) and reverting it later +- refreshing screenshots or adding a Playground preview blueprint + +To ship new plugin code, use [WordPress.org Release](./wordpress-org-release.md) instead. That workflow also publishes `readme.txt` as part of every release, but not the assets, see [Common tasks](#common-tasks). + +How it works: + +- **Validate:** with `SYNC_README`, `readme.txt` must be a regular file (not a symlink) with exactly one `Stable tag:` line before the first `== Section ==`. With `SYNC_ASSETS`, every file in `ASSETS_DIR` must be a [supported asset](#supported-asset-files). +- **Check the version:** with `SYNC_README`, the `Stable tag` in Git must equal the one in SVN trunk, and that tag must exist. Only `trunk/readme.txt`, the tag's `readme.txt`, and `/assets` are checked out from SVN, never plugin code. +- **Sync:** `readme.txt` is copied into `tags//` (which WordPress.org renders) and `trunk/`, see [Trunk previews](#trunk-previews) and [Release Confirmation](#release-confirmation). `ASSETS_DIR` is mirrored to `/assets`, so files removed from Git are removed from WordPress.org too. The run fails if it would remove the last icon or banner, or change anything other than these files, and warns if it removes all screenshots. +- **Publish:** the changes are shown in the job summary, then committed in a single SVN commit, or uploaded as an artifact in a [dry run](#dry-run). A run without changes succeeds without committing. + +> [!IMPORTANT] +> This workflow never creates tags, never changes the `Stable tag`, and never touches plugin code. Changing the `Stable tag` means publishing a different version, which is a release. + +> [!NOTE] +> WordPress.org renders the plugin page from the `readme.txt` in the tag that `Stable tag` points to, not from trunk. The WordPress.org [plugin developer FAQ](https://developer.wordpress.org/plugins/wordpress-org/plugin-developer-faq/#do-i-need-to-release-a-new-version-of-my-plugin-every-time-i-update-the-readme) explicitly allows cosmetic readme and asset changes without a new release, as long as both trunk and the tag are updated. + +> [!NOTE] +> `Requires at least` and `Requires PHP` in `readme.txt` aren't just displayed: unless the main plugin file declares them, WordPress uses them to block installs and updates of the published version on sites that don't meet them. The workflow warns when a run changes them. + +> [!NOTE] +> Assets are served through a CDN and cached heavily. Changes can take a few minutes, and under high load up to several hours, to show up on the plugin page. + +## Simple usage example + +This workflow cannot be triggered directly. Create a workflow file in your plugin's repository that calls it via `uses:`, as shown below. + +```yml +name: Update WordPress.org plugin page +on: + workflow_dispatch: + inputs: + GIT_REF: + description: 'Git tag or branch to read readme.txt and assets from' + required: true + SYNC_README: + description: 'Update readme.txt' + type: boolean + default: true + SYNC_ASSETS: + description: 'Update banners, icons, screenshots, and blueprints' + type: boolean + default: true + DRY_RUN: + description: 'Upload the changes as an artifact instead of committing to SVN' + type: boolean + default: true +jobs: + update-plugin-page: + uses: inpsyde/reusable-workflows/.github/workflows/wordpress-org-plugin-page.yml@main + with: + SVN_PLUGIN_SLUG: my-plugin + GIT_REF: ${{ inputs.GIT_REF }} + SYNC_README: ${{ inputs.SYNC_README }} + SYNC_ASSETS: ${{ inputs.SYNC_ASSETS }} + DRY_RUN: ${{ inputs.DRY_RUN }} + secrets: + SVN_USERNAME: ${{ secrets.SVN_USERNAME }} + SVN_PASSWORD: ${{ secrets.SVN_PASSWORD }} +``` + +For which ref to pass as `GIT_REF`, see [Choosing `GIT_REF`](#choosing-git_ref). + +> [!IMPORTANT] +> `DRY_RUN` defaults to `true`, so a caller that doesn't pass it only previews the changes. Set `DRY_RUN: false` to actually update the plugin page. + +## Choosing `GIT_REF` + +The workflow publishes `readme.txt` and `ASSETS_DIR` from `GIT_REF` as they are, and ignores the plugin code. In `GIT_REF`, both should match what is currently published, plus only the change you want to publish. + +To get there, create a branch from the latest release: its Git tag, or the commit you released from if you don't tag releases. If the plugin page was updated with this workflow after the release, create it from that update's branch instead, or your run reverts that update. + +```shell +git switch -c plugin-page/tested-up-to-6.9 v1.2.3 +# edit readme.txt, e.g. "Tested up to: 6.9" +git commit -am "Bump Tested up to 6.9" +git push -u origin HEAD +``` + +1. Run the workflow with `GIT_REF: plugin-page/tested-up-to-6.9` and `DRY_RUN: true`. In the job summary, the SVN changes and the `readme.txt` diff should show only your change. +2. Run it again with `DRY_RUN: false`. +3. Merge the branch into your development branch, so the next release keeps the change. + +> [!WARNING] +> A development branch is risky as `GIT_REF`. Until the next release, its `Stable tag` usually still names the published version, so the Stable tag check passes. But its `readme.txt` may already contain a changelog entry, upgrade notice, or FAQ entries for the next version, and its assets may include screenshots of unreleased features. The workflow publishes all of it without a warning. + +## Common tasks + +Make each change on a branch created as described in [Choosing `GIT_REF`](#choosing-git_ref), and check the dry run before publishing. + +| Task | Change on the branch | `SYNC_README` | `SYNC_ASSETS` | +|---|---|---|---| +| Bump `Tested up to`, add or remove a promo link | `readme.txt` | `true` | `false` | +| Campaign banner | Replace `banner-*.png` in `.wordpress-org/` | `false` | `true` | +| Revert the campaign banner | `git revert` the banner commit, and merge the revert into your development branch too | `false` | `true` | +| New screenshots | `screenshot-N.png` and its caption in `== Screenshots ==` | `true` | `true` | +| Playground preview | Add `blueprints/blueprint.json`, then make the preview public in the plugin's **Advanced View** | `false` | `true` | +| Keep assets current after each release | None, see below | `false` | `true` | + +The release workflow doesn't publish `.wordpress-org/` (it's excluded via `.distignore`, see [Adopting the workflow](#adopting-the-workflow)), so assets changed in Git only reach WordPress.org with this workflow. To publish them with every release, run it right after the release: + +```yml +jobs: + release: + uses: inpsyde/reusable-workflows/.github/workflows/wordpress-org-release.yml@main + with: + SVN_PLUGIN_SLUG: my-plugin + PLUGIN_VERSION: ${{ inputs.PLUGIN_VERSION }} + GIT_REF: ${{ inputs.GIT_REF }} + UPDATE_TRUNK_ONLY: false + secrets: + SVN_USERNAME: ${{ secrets.SVN_USERNAME }} + SVN_PASSWORD: ${{ secrets.SVN_PASSWORD }} + plugin-page: + needs: release + uses: inpsyde/reusable-workflows/.github/workflows/wordpress-org-plugin-page.yml@main + with: + SVN_PLUGIN_SLUG: my-plugin + GIT_REF: ${{ inputs.GIT_REF }} + SYNC_README: false # the release already published readme.txt + DRY_RUN: false + secrets: + SVN_USERNAME: ${{ secrets.SVN_USERNAME }} + SVN_PASSWORD: ${{ secrets.SVN_PASSWORD }} +``` + +## Advanced usage: requiring manual approval + +To require approval before the plugin page is updated, add an `environment:` key to the calling job and configure protection rules (required reviewers, wait timers, etc.) for that environment in your repository settings under **Settings → Environments**. + +```yml +jobs: + update-plugin-page: + environment: wordpress-org # enforces protection rules configured in repository settings + uses: inpsyde/reusable-workflows/.github/workflows/wordpress-org-plugin-page.yml@main + with: + SVN_PLUGIN_SLUG: my-plugin + GIT_REF: ${{ inputs.GIT_REF }} + DRY_RUN: false + secrets: + SVN_USERNAME: ${{ secrets.SVN_USERNAME }} + SVN_PASSWORD: ${{ secrets.SVN_PASSWORD }} +``` + +> [!NOTE] +> The `environment:` key alone does nothing: protection rules must be explicitly configured in repository settings. An environment with no rules configured provides no approval gate. + +> [!WARNING] +> An environment's **deployment branch** rule restricts the ref the *calling* workflow runs from, not `GIT_REF`. With `GIT_REF` as a free-text input, anyone allowed to run the workflow can publish the readme and assets from any branch, regardless of the environment rule. This includes pull request refs like `refs/pull//head`, so even a fork's pull request can be published. If you rely on branch rules, pass `${{ github.sha }}` or `${{ github.ref_name }}` as `GIT_REF`, or offer a `choice` input instead. + +To use a branch created as described in [Choosing `GIT_REF`](#choosing-git_ref), run the calling workflow from that branch with `GIT_REF: ${{ github.sha }}`, and allow only `plugin-page/*` branches, with `if:` as below or with the environment's deployment branch rule. Both only check the branch name, not what the branch contains, so check the dry run either way. + +```yml +on: + workflow_dispatch: + inputs: + DRY_RUN: + description: 'Upload the changes as an artifact instead of committing to SVN' + type: boolean + default: true +jobs: + update-plugin-page: + if: startsWith(github.ref, 'refs/heads/plugin-page/') # runs from other branches are skipped + environment: wordpress-org + uses: inpsyde/reusable-workflows/.github/workflows/wordpress-org-plugin-page.yml@main + with: + SVN_PLUGIN_SLUG: my-plugin + GIT_REF: ${{ github.sha }} + DRY_RUN: ${{ inputs.DRY_RUN }} + secrets: + SVN_USERNAME: ${{ secrets.SVN_USERNAME }} + SVN_PASSWORD: ${{ secrets.SVN_PASSWORD }} +``` + +The calling workflow file must exist on that branch. If the release is older than the file, copy it over and commit it, e.g. `git restore --source=develop -- .github/workflows/update-plugin-page.yml`. + +## Adopting the workflow + +Assets are mirrored, so the assets directory in Git must contain **every** asset that should stay on WordPress.org. Before the first run, import the current assets from SVN: + +```shell +svn export https://plugins.svn.wordpress.org/my-plugin/assets .wordpress-org +``` + +If `.wordpress-org` already exists, add `--force` to export into it. + +Then: + +1. Commit the `.wordpress-org` directory. Don't store it in Git LFS, see [Supported asset files](#supported-asset-files). +2. Add `.wordpress-org/` to `.distignore` so the assets don't end up in the plugin package or in SVN trunk during releases. +3. Run the workflow with `DRY_RUN: true`. The SVN changes in the job summary should list **no content changes** in `/assets`. Property-only changes (` M`) are expected where existing images lack the correct `svn:mime-type`, or existing blueprints have one. +4. Fix any files the validation rejects. Some are ignored by WordPress.org (e.g. `icon_128x128.png`), others are only rejected by this workflow's stricter rules (e.g. a raster fallback for `icon.svg`). + +## Trunk previews + +If SVN `trunk/readme.txt` differs from `tags//readme.txt` before the sync, trunk holds unreleased changes, for example a preview published with the release workflow's `UPDATE_TRUNK_ONLY` mode. Overwriting it would silently revert those changes, so in that case the workflow only updates the tag's `readme.txt` and shows a warning, both as an annotation and in the job summary. Make sure the same change is part of the upcoming release, so that it isn't lost when the next version is published. + +## Release Confirmation + +[Release Confirmation](https://developer.wordpress.org/plugins/wordpress-org/release-confirmation-emails/) is an opt-in WordPress.org feature that requires committers to confirm every release by email. Plugin committers can check whether it is enabled for the plugin on WordPress.org. + +> [!WARNING] +> For plugins with Release Confirmation enabled, the handbook explicitly states that released tags can't be altered, including the readme (e.g. for `Tested up to`). Updating `readme.txt` with this workflow is therefore **not officially supported** for these plugins. Use it at your own risk, or keep `SYNC_README: false` and ship readme changes with the next release. + +Judging by the plugin directory importer's code, the scenario appears to be handled: WordPress.org treats any commit to an already released tag as a [modified release](https://github.com/WordPress/wordpress.org/commit/8d1727f0e331ccfebce432bdfcf4c30db16e2803), even one that only changes `readme.txt`. Updating `tags//readme.txt` then: + +- reopens that release for confirmation and sends the confirmation email to all committers again +- restarts the release cooldown, a delay WordPress.org can apply before it serves a new release +- keeps the plugin page from updating until the release is confirmed again +- marks the release's ZIP as not built, so it is rebuilt with the new `readme.txt` once the release is confirmed again + +This behavior isn't documented and may change. Whenever the tag's `readme.txt` changes, the workflow points this out in a notice and in the job summary. + +Asset-only runs (`SYNC_README: false`) don't touch any tag and are not affected. + +## Supported asset files + +Any file with a name WordPress.org would ignore fails the validation. On top of the WordPress.org rules, this workflow requires: + +- a raster fallback for `icon.svg` +- at least one default (non-localized) icon and banner, if the plugin page has them today. A run that would remove the last one fails, which catches an incomplete assets directory. To remove them on purpose, delete them by hand in SVN +- at most 10 blueprints (WordPress.org would silently import only the first 10) +- banners and raster icons with exactly the dimensions their name says, and raster files in the format their extension says +- regular files only: symlinks and subdirectories other than `blueprints/` are rejected + +Hidden files like `.gitkeep` are ignored. + +| Type | File names | Formats | Max size | +|---|---|---|---| +| Banner | `banner-772x250`, `banner-1544x500` | png, jpg, jpeg, gif | 4 MB | +| Icon | `icon-128x128`, `icon-256x256`, `icon.svg` | png, jpg, jpeg, gif (`icon.svg` requires one of them as fallback) | 1 MB | +| Screenshot | `screenshot-1`, `screenshot-2`, … | png, jpg, jpeg, gif | 10 MB | +| Blueprint | `blueprints/blueprint.json`, `blueprints/blueprint-.json` | JSON object or array, max. 10 files | 100 KB | + +Banners, icons, and screenshots can be localized with an `-rtl` and/or a locale suffix, e.g. `banner-772x250-rtl.png`, `banner-1544x500-de.png`, or `screenshot-1-es_ES.png`. Screenshot captions come from the `== Screenshots ==` section of `readme.txt`. See [Plugin Assets](https://developer.wordpress.org/plugins/wordpress-org/plugin-assets/) for details. + +> [!WARNING] +> Git LFS is not supported. `actions/checkout` doesn't fetch LFS files by default, so the workflow would see small pointer files instead of images. The format check rejects them. + +> [!NOTE] +> A blueprint enables the "Live Preview" button for plugin committers only. To show it to everyone, a committer must set the preview to public in the plugin's **Advanced View** on WordPress.org. See [Previews and Blueprints](https://developer.wordpress.org/plugins/wordpress-org/previews-and-blueprints/). + +## Configuration parameters + +### Inputs + +| Name | Required | Default | Description | +|---|---|---|---| +| `SVN_PLUGIN_SLUG` | yes | — | WordPress.org plugin slug (e.g. `my-plugin`) | +| `GIT_REF` | yes | — | Git ref to read `readme.txt` and the assets directory from (tag, branch, or full 40-character commit SHA) | +| `SYNC_README` | no | `true` | Update `readme.txt` in SVN trunk and in the tag referenced by `Stable tag` | +| `SYNC_ASSETS` | no | `true` | Mirror `ASSETS_DIR` to the SVN `/assets` directory | +| `ASSETS_DIR` | no | `.wordpress-org` | Directory in the Git repository holding the WordPress.org assets | +| `DRY_RUN` | no | `true` | Upload the files that would be committed as an artifact instead of committing to SVN | + +At least one of `SYNC_README` and `SYNC_ASSETS` must be enabled. + +### Secrets + +| Name | Required | Description | +|---|---|---| +| `SVN_USERNAME` | yes | WordPress.org SVN username | +| `SVN_PASSWORD` | yes | WordPress.org SVN password | + +> [!NOTE] +> WordPress.org SVN does not support SSH keys or tokens. The `SVN_USERNAME` and `SVN_PASSWORD` secrets are the only supported authentication method. + +## Dry run + +With `DRY_RUN: true`, nothing is committed. The job summary on the run page shows every file that would be added (`A`), deleted (`D`), modified (`M`), or have its properties changed (` M`), lists removed files separately, and shows the `readme.txt` diff. + +If anything would change, an artifact named `-plugin-page` is uploaded. It contains exactly what would be committed, in its final state, each only if it would change: + +- `tags//readme.txt` +- `trunk/readme.txt` (see [Trunk previews](#trunk-previews)) +- `assets/`: the complete assets directory, if anything in it would change + +If nothing would change, no artifact is uploaded and the job summary says that the plugin page is already up to date. + +## Troubleshooting + +Changes are committed in a single atomic SVN commit, so **Re-run failed jobs** is always safe: the re-run either commits the changes or reports that the plugin page is already up to date. There is no need to fix anything in SVN by hand. If `GIT_REF` is a branch, a re-run uses its current state, which may include newer commits. + +- **Stable tag mismatch:** `readme.txt` in `GIT_REF` doesn't describe the published version, e.g. it comes from a development branch or a release happened since. See [Choosing `GIT_REF`](#choosing-git_ref). +- **"Exactly one 'Stable tag:' line":** remove duplicate `Stable tag:` lines, or move the line into the header before the first `== Section ==`. +- **Asset rejected:** the log says why. See [Supported asset files](#supported-asset-files) for names, formats, sizes, and dimensions. +- **Concurrent SVN commit:** someone else committed in the meantime, e.g. a release. Wait until that run has finished, then re-run. If it was a release, the re-run fails the Stable tag check: run the workflow again with a `GIT_REF` that matches the new version. +- **SVN commit timed out, or a network error:** the commit may still have gone through. Re-run to find out. +- **trunk/readme.txt left unchanged:** trunk holds unreleased changes, see [Trunk previews](#trunk-previews). +- **Plugin page not updated:** wait for the CDN cache (minutes, sometimes hours). With [Release Confirmation](#release-confirmation), the release must be confirmed again first. diff --git a/docs/wordpress-org-release.md b/docs/wordpress-org-release.md index 87d85283..1ef5d79e 100644 --- a/docs/wordpress-org-release.md +++ b/docs/wordpress-org-release.md @@ -131,7 +131,7 @@ To preview trunk before publishing, run the workflow twice with the same `PLUGIN > The trunk-only check exists because [WordPress.org serves the plugin from trunk instead of a tag when `Stable tag` points to a tag that doesn't exist](https://developer.wordpress.org/plugins/wordpress-org/how-your-readme-txt-works/#how-the-readme-is-parsed) — without it, a trunk-only sync could accidentally push the in-progress release out as "stable" to regular users. > [!NOTE] -> WordPress.org reads `readme.txt` from the tag that `Stable tag` points to, not from trunk. Updating `readme.txt` in trunk alone will not update the plugin page — a new tag must be created. +> WordPress.org reads `readme.txt` from the tag that `Stable tag` points to, not from trunk. Updating `readme.txt` in trunk alone will not update the plugin page. To change the plugin page (readme, banners, icons, screenshots) without releasing a new version, use [WordPress.org Plugin Page](./wordpress-org-plugin-page.md). ## Configuration parameters @@ -165,3 +165,6 @@ The following files are always excluded from the SVN sync, regardless of `.disti - `.distignore` itself Additional exclusions can be specified via a `.distignore` file in the repository root (same format used by `wp dist-archive`). + +> [!TIP] +> If the repository keeps its WordPress.org assets in Git for the [WordPress.org Plugin Page](./wordpress-org-plugin-page.md) workflow (by default in `.wordpress-org/`), add that directory to `.distignore` so it isn't synced to trunk.