Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
149 changes: 149 additions & 0 deletions .github/workflows/generate-changed-files.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,149 @@
##
# 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.
#
# 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.
##
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:
# - 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.
# - Uploads the list as a downloadable workflow artifact.
generate:
name: Generate changed files list
runs-on: ubuntu-24.04
permissions:
contents: read
timeout-minutes: 20
if: ${{ github.repository == 'WordPress/wordpress-develop' || github.event_name == 'workflow_dispatch' }}

steps:
# 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}"

# 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 --no-renames "refs/tags/${PREVIOUS_TAG}" "refs/tags/${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."
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
Loading