From 48869814ac6b03ff5d8414254287b950c9d6d108 Mon Sep 17 00:00:00 2001 From: AKSHAT2802 Date: Wed, 3 Jun 2026 15:15:24 +0530 Subject: [PATCH 1/3] Build/Test Tools: Add workflow to generate changed files list on new version tags. Adds a GitHub Action that automatically generates a list of files changed between the newly tagged release and the previous release tag. This removes the need for contributors to manually run SVN or Git commands to produce the list used to update HelpHub documentation for each release. Fixes #64003. --- .github/workflows/generate-changed-files.yml | 109 +++++++++++++++++++ 1 file changed, 109 insertions(+) create mode 100644 .github/workflows/generate-changed-files.yml diff --git a/.github/workflows/generate-changed-files.yml b/.github/workflows/generate-changed-files.yml new file mode 100644 index 0000000000000..e829d937ce3de --- /dev/null +++ b/.github/workflows/generate-changed-files.yml @@ -0,0 +1,109 @@ +## +# A GitHub Action that generates a list of files changed between the newly +# tagged WordPress release and the previous release tag. +# +# This list is useful for updating documentation such as the HelpHub +# "Files Changed" section for each release. It replaces the need to manually +# run SVN or Git commands to produce the same output. +# +# Contributors can also run this workflow manually via the "workflow_dispatch" +# event, providing custom tag inputs to compare any two releases. +## +name: Generate Changed Files List + +on: + push: + tags: + - '[0-9]+.[0-9]+' + - '[0-9]+.[0-9]+.[0-9]+' + workflow_dispatch: + inputs: + compare_tag: + description: 'The newer tag to compare (e.g. 6.6.2)' + required: true + type: string + base_tag: + description: 'The older base tag to compare against (e.g. 6.6.1)' + required: true + type: string + +# Disable permissions for all available scopes by default. +# Any needed permissions should be configured at the job level. +permissions: {} + +jobs: + # Generates a list of files changed between two version tags. + # + # Performs the following steps: + # - Checks out the repository with full history to access all tags. + # - Determines the current and previous version tags. + # - Generates a sorted list of changed files using git diff. + # - Displays the list in the workflow run summary. + # - Uploads the list as a downloadable workflow artifact. + generate: + name: Generate changed files list + runs-on: ubuntu-24.04 + permissions: + contents: read + timeout-minutes: 10 + if: ${{ github.repository == 'WordPress/wordpress-develop' || github.event_name == 'workflow_dispatch' }} + + steps: + - name: Checkout repository + uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 + with: + fetch-depth: 0 + show-progress: ${{ runner.debug == '1' && 'true' || 'false' }} + persist-credentials: false + + - name: Determine the tags to compare + id: tags + run: | + if [[ "${{ github.event_name }}" == "workflow_dispatch" ]]; then + CURRENT_TAG="${{ inputs.compare_tag }}" + PREVIOUS_TAG="${{ inputs.base_tag }}" + else + CURRENT_TAG="${GITHUB_REF_NAME}" + # Find the most recent version tag preceding the current one. + PREVIOUS_TAG=$( git tag --sort=-version:refname | grep -E '^[0-9]+\.[0-9]+(\.[0-9]+)?$' | grep -v "^${CURRENT_TAG}$" | head -1 ) + fi + + if [[ -z "${PREVIOUS_TAG}" ]]; then + echo "::error::Could not determine the previous version tag to compare against." + exit 1 + fi + + echo "Comparing ${PREVIOUS_TAG} to ${CURRENT_TAG}." + echo "current_tag=${CURRENT_TAG}" >> "$GITHUB_OUTPUT" + echo "previous_tag=${PREVIOUS_TAG}" >> "$GITHUB_OUTPUT" + + - name: Generate list of changed files + id: diff + run: | + CURRENT_TAG="${{ steps.tags.outputs.current_tag }}" + PREVIOUS_TAG="${{ steps.tags.outputs.previous_tag }}" + + git diff --name-status "${PREVIOUS_TAG}" "${CURRENT_TAG}" | sort > changed-files.txt + + FILE_COUNT=$( wc -l < changed-files.txt | tr -d ' ' ) + + { + echo "## Files Changed: \`${PREVIOUS_TAG}\` → \`${CURRENT_TAG}\`" + echo "" + echo "**${FILE_COUNT} file(s) changed** between \`${PREVIOUS_TAG}\` and \`${CURRENT_TAG}\`." + echo "" + echo "Status codes: \`A\` = Added, \`D\` = Deleted, \`M\` = Modified, \`R\` = Renamed." + echo "" + echo '```' + cat changed-files.txt + echo '```' + } >> "$GITHUB_STEP_SUMMARY" + + echo "file_count=${FILE_COUNT}" >> "$GITHUB_OUTPUT" + + - name: Upload changed files list as artifact + uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 + with: + name: changed-files-${{ steps.tags.outputs.current_tag }} + path: changed-files.txt + if-no-files-found: error \ No newline at end of file From 334c41d8908ebad0a4f2a3f569324fc65009ad48 Mon Sep 17 00:00:00 2001 From: AKSHAT2802 Date: Wed, 3 Jun 2026 15:48:18 +0530 Subject: [PATCH 2/3] Build/Test Tools: Refactor environment variable usage in changed files generation workflow --- .github/workflows/generate-changed-files.yml | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/.github/workflows/generate-changed-files.yml b/.github/workflows/generate-changed-files.yml index e829d937ce3de..6e8f899c26dfa 100644 --- a/.github/workflows/generate-changed-files.yml +++ b/.github/workflows/generate-changed-files.yml @@ -58,10 +58,14 @@ jobs: - name: Determine the tags to compare id: tags + env: + EVENT_NAME: ${{ github.event_name }} + INPUT_COMPARE_TAG: ${{ inputs.compare_tag }} + INPUT_BASE_TAG: ${{ inputs.base_tag }} run: | - if [[ "${{ github.event_name }}" == "workflow_dispatch" ]]; then - CURRENT_TAG="${{ inputs.compare_tag }}" - PREVIOUS_TAG="${{ inputs.base_tag }}" + if [[ "${EVENT_NAME}" == "workflow_dispatch" ]]; then + CURRENT_TAG="${INPUT_COMPARE_TAG}" + PREVIOUS_TAG="${INPUT_BASE_TAG}" else CURRENT_TAG="${GITHUB_REF_NAME}" # Find the most recent version tag preceding the current one. @@ -79,10 +83,10 @@ jobs: - name: Generate list of changed files id: diff + env: + CURRENT_TAG: ${{ steps.tags.outputs.current_tag }} + PREVIOUS_TAG: ${{ steps.tags.outputs.previous_tag }} run: | - CURRENT_TAG="${{ steps.tags.outputs.current_tag }}" - PREVIOUS_TAG="${{ steps.tags.outputs.previous_tag }}" - git diff --name-status "${PREVIOUS_TAG}" "${CURRENT_TAG}" | sort > changed-files.txt FILE_COUNT=$( wc -l < changed-files.txt | tr -d ' ' ) From 5a85d1df58e4a0e6e10914cfe32c8de425c20c87 Mon Sep 17 00:00:00 2001 From: c-akakkad Date: Sat, 28 Nov 2026 14:25:19 +0530 Subject: [PATCH 3/3] Build/Test Tools: Compare built release tags and fix previous tag selection. Select the tag sorted directly below the pushed tag as the previous release, so maintenance releases are compared within their own branch (7.0.8 against 7.0.7, even when 7.1.x exists). Compare tags in the built WordPress/WordPress repository instead of this one, so the list reflects the files that ship in a release, matching `svn diff --summarize` on core.svn.wordpress.org. Run steps with `shell: bash` so failures in pipelines are caught, and validate both tags before comparing them. See #64003. --- .github/workflows/generate-changed-files.yml | 74 +++++++++++++++----- 1 file changed, 55 insertions(+), 19 deletions(-) diff --git a/.github/workflows/generate-changed-files.yml b/.github/workflows/generate-changed-files.yml index 6e8f899c26dfa..e49c027914c82 100644 --- a/.github/workflows/generate-changed-files.yml +++ b/.github/workflows/generate-changed-files.yml @@ -6,6 +6,11 @@ # "Files Changed" section for each release. It replaces the need to manually # run SVN or Git commands to produce the same output. # +# The comparison is made against the built WordPress repository +# (WordPress/WordPress, a mirror of core.svn.wordpress.org) so that the list +# reflects the files that ship in a release, rather than the development +# sources in this repository. +# # Contributors can also run this workflow manually via the "workflow_dispatch" # event, providing custom tag inputs to compare any two releases. ## @@ -35,7 +40,7 @@ jobs: # Generates a list of files changed between two version tags. # # Performs the following steps: - # - Checks out the repository with full history to access all tags. + # - Clones the built WordPress repository without file contents. # - Determines the current and previous version tags. # - Generates a sorted list of changed files using git diff. # - Displays the list in the workflow run summary. @@ -45,61 +50,92 @@ jobs: runs-on: ubuntu-24.04 permissions: contents: read - timeout-minutes: 10 + timeout-minutes: 20 if: ${{ github.repository == 'WordPress/wordpress-develop' || github.event_name == 'workflow_dispatch' }} steps: - - name: Checkout repository - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 - with: - fetch-depth: 0 - show-progress: ${{ runner.debug == '1' && 'true' || 'false' }} - persist-credentials: false + # Only the commit and tree objects are needed to list changed file names, + # so file contents are left out to keep the clone small. + - name: Clone the built WordPress repository + shell: bash + run: git clone --quiet --filter=blob:none --no-checkout https://github.com/WordPress/WordPress.git wordpress - name: Determine the tags to compare id: tags + shell: bash + working-directory: wordpress env: EVENT_NAME: ${{ github.event_name }} INPUT_COMPARE_TAG: ${{ inputs.compare_tag }} INPUT_BASE_TAG: ${{ inputs.base_tag }} run: | + VERSION_PATTERN='^[0-9]+\.[0-9]+(\.[0-9]+)?$' + if [[ "${EVENT_NAME}" == "workflow_dispatch" ]]; then CURRENT_TAG="${INPUT_COMPARE_TAG}" PREVIOUS_TAG="${INPUT_BASE_TAG}" + + for TAG in "${CURRENT_TAG}" "${PREVIOUS_TAG}"; do + if [[ ! "${TAG}" =~ ${VERSION_PATTERN} ]]; then + echo "::error::'${TAG}' is not a valid version tag (expected e.g. 6.6 or 6.6.2)." + exit 1 + fi + done else CURRENT_TAG="${GITHUB_REF_NAME}" - # Find the most recent version tag preceding the current one. - PREVIOUS_TAG=$( git tag --sort=-version:refname | grep -E '^[0-9]+\.[0-9]+(\.[0-9]+)?$' | grep -v "^${CURRENT_TAG}$" | head -1 ) - fi - if [[ -z "${PREVIOUS_TAG}" ]]; then - echo "::error::Could not determine the previous version tag to compare against." - exit 1 + # The built repository is tagged separately from this one and can lag + # behind it, so wait for the new tag to appear there. + for ATTEMPT in {1..10}; do + if git rev-parse --verify --quiet "refs/tags/${CURRENT_TAG}" > /dev/null; then + break + fi + echo "Tag ${CURRENT_TAG} is not in the built repository yet (attempt ${ATTEMPT} of 10). Retrying in 60 seconds." + sleep 60 + git fetch --quiet --tags origin + done + + # The previous release is the tag sorted directly below the current one. + # This keeps maintenance releases within their own branch (7.0.8 is + # compared to 7.0.7, even when 7.1.3 exists), and compares a major + # release to the latest release of the previous branch (7.0 to 6.9.4). + PREVIOUS_TAG=$( git tag --list --sort=-version:refname | grep -E "${VERSION_PATTERN}" | grep -x -F -A1 "${CURRENT_TAG}" | sed -n '2p' || true ) fi + for TAG in "${CURRENT_TAG}" "${PREVIOUS_TAG}"; do + if [[ -z "${TAG}" ]] || ! git rev-parse --verify --quiet "refs/tags/${TAG}" > /dev/null; then + echo "::error::Could not find the tag '${TAG}' in the built WordPress repository." + exit 1 + fi + done + echo "Comparing ${PREVIOUS_TAG} to ${CURRENT_TAG}." echo "current_tag=${CURRENT_TAG}" >> "$GITHUB_OUTPUT" echo "previous_tag=${PREVIOUS_TAG}" >> "$GITHUB_OUTPUT" + # Rename detection is turned off because it needs file contents, which the + # clone leaves out. A renamed file is listed as a deletion and an addition. - name: Generate list of changed files id: diff + shell: bash + working-directory: wordpress env: CURRENT_TAG: ${{ steps.tags.outputs.current_tag }} PREVIOUS_TAG: ${{ steps.tags.outputs.previous_tag }} run: | - git diff --name-status "${PREVIOUS_TAG}" "${CURRENT_TAG}" | sort > changed-files.txt + git diff --name-status --no-renames "refs/tags/${PREVIOUS_TAG}" "refs/tags/${CURRENT_TAG}" | sort > ../changed-files.txt - FILE_COUNT=$( wc -l < changed-files.txt | tr -d ' ' ) + FILE_COUNT=$( wc -l < ../changed-files.txt | tr -d ' ' ) { echo "## Files Changed: \`${PREVIOUS_TAG}\` → \`${CURRENT_TAG}\`" echo "" echo "**${FILE_COUNT} file(s) changed** between \`${PREVIOUS_TAG}\` and \`${CURRENT_TAG}\`." echo "" - echo "Status codes: \`A\` = Added, \`D\` = Deleted, \`M\` = Modified, \`R\` = Renamed." + echo "Status codes: \`A\` = Added, \`D\` = Deleted, \`M\` = Modified." echo "" echo '```' - cat changed-files.txt + cat ../changed-files.txt echo '```' } >> "$GITHUB_STEP_SUMMARY" @@ -110,4 +146,4 @@ jobs: with: name: changed-files-${{ steps.tags.outputs.current_tag }} path: changed-files.txt - if-no-files-found: error \ No newline at end of file + if-no-files-found: error