Skip to content

Commit 5a85d1d

Browse files
committed
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.
1 parent 24ffbbf commit 5a85d1d

1 file changed

Lines changed: 55 additions & 19 deletions

File tree

‎.github/workflows/generate-changed-files.yml‎

Lines changed: 55 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,11 @@
66
# "Files Changed" section for each release. It replaces the need to manually
77
# run SVN or Git commands to produce the same output.
88
#
9+
# The comparison is made against the built WordPress repository
10+
# (WordPress/WordPress, a mirror of core.svn.wordpress.org) so that the list
11+
# reflects the files that ship in a release, rather than the development
12+
# sources in this repository.
13+
#
914
# Contributors can also run this workflow manually via the "workflow_dispatch"
1015
# event, providing custom tag inputs to compare any two releases.
1116
##
@@ -35,7 +40,7 @@ jobs:
3540
# Generates a list of files changed between two version tags.
3641
#
3742
# Performs the following steps:
38-
# - Checks out the repository with full history to access all tags.
43+
# - Clones the built WordPress repository without file contents.
3944
# - Determines the current and previous version tags.
4045
# - Generates a sorted list of changed files using git diff.
4146
# - Displays the list in the workflow run summary.
@@ -45,61 +50,92 @@ jobs:
4550
runs-on: ubuntu-24.04
4651
permissions:
4752
contents: read
48-
timeout-minutes: 10
53+
timeout-minutes: 20
4954
if: ${{ github.repository == 'WordPress/wordpress-develop' || github.event_name == 'workflow_dispatch' }}
5055

5156
steps:
52-
- name: Checkout repository
53-
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
54-
with:
55-
fetch-depth: 0
56-
show-progress: ${{ runner.debug == '1' && 'true' || 'false' }}
57-
persist-credentials: false
57+
# Only the commit and tree objects are needed to list changed file names,
58+
# so file contents are left out to keep the clone small.
59+
- name: Clone the built WordPress repository
60+
shell: bash
61+
run: git clone --quiet --filter=blob:none --no-checkout https://github.com/WordPress/WordPress.git wordpress
5862

5963
- name: Determine the tags to compare
6064
id: tags
65+
shell: bash
66+
working-directory: wordpress
6167
env:
6268
EVENT_NAME: ${{ github.event_name }}
6369
INPUT_COMPARE_TAG: ${{ inputs.compare_tag }}
6470
INPUT_BASE_TAG: ${{ inputs.base_tag }}
6571
run: |
72+
VERSION_PATTERN='^[0-9]+\.[0-9]+(\.[0-9]+)?$'
73+
6674
if [[ "${EVENT_NAME}" == "workflow_dispatch" ]]; then
6775
CURRENT_TAG="${INPUT_COMPARE_TAG}"
6876
PREVIOUS_TAG="${INPUT_BASE_TAG}"
77+
78+
for TAG in "${CURRENT_TAG}" "${PREVIOUS_TAG}"; do
79+
if [[ ! "${TAG}" =~ ${VERSION_PATTERN} ]]; then
80+
echo "::error::'${TAG}' is not a valid version tag (expected e.g. 6.6 or 6.6.2)."
81+
exit 1
82+
fi
83+
done
6984
else
7085
CURRENT_TAG="${GITHUB_REF_NAME}"
71-
# Find the most recent version tag preceding the current one.
72-
PREVIOUS_TAG=$( git tag --sort=-version:refname | grep -E '^[0-9]+\.[0-9]+(\.[0-9]+)?$' | grep -v "^${CURRENT_TAG}$" | head -1 )
73-
fi
7486
75-
if [[ -z "${PREVIOUS_TAG}" ]]; then
76-
echo "::error::Could not determine the previous version tag to compare against."
77-
exit 1
87+
# The built repository is tagged separately from this one and can lag
88+
# behind it, so wait for the new tag to appear there.
89+
for ATTEMPT in {1..10}; do
90+
if git rev-parse --verify --quiet "refs/tags/${CURRENT_TAG}" > /dev/null; then
91+
break
92+
fi
93+
echo "Tag ${CURRENT_TAG} is not in the built repository yet (attempt ${ATTEMPT} of 10). Retrying in 60 seconds."
94+
sleep 60
95+
git fetch --quiet --tags origin
96+
done
97+
98+
# The previous release is the tag sorted directly below the current one.
99+
# This keeps maintenance releases within their own branch (7.0.8 is
100+
# compared to 7.0.7, even when 7.1.3 exists), and compares a major
101+
# release to the latest release of the previous branch (7.0 to 6.9.4).
102+
PREVIOUS_TAG=$( git tag --list --sort=-version:refname | grep -E "${VERSION_PATTERN}" | grep -x -F -A1 "${CURRENT_TAG}" | sed -n '2p' || true )
78103
fi
79104
105+
for TAG in "${CURRENT_TAG}" "${PREVIOUS_TAG}"; do
106+
if [[ -z "${TAG}" ]] || ! git rev-parse --verify --quiet "refs/tags/${TAG}" > /dev/null; then
107+
echo "::error::Could not find the tag '${TAG}' in the built WordPress repository."
108+
exit 1
109+
fi
110+
done
111+
80112
echo "Comparing ${PREVIOUS_TAG} to ${CURRENT_TAG}."
81113
echo "current_tag=${CURRENT_TAG}" >> "$GITHUB_OUTPUT"
82114
echo "previous_tag=${PREVIOUS_TAG}" >> "$GITHUB_OUTPUT"
83115
116+
# Rename detection is turned off because it needs file contents, which the
117+
# clone leaves out. A renamed file is listed as a deletion and an addition.
84118
- name: Generate list of changed files
85119
id: diff
120+
shell: bash
121+
working-directory: wordpress
86122
env:
87123
CURRENT_TAG: ${{ steps.tags.outputs.current_tag }}
88124
PREVIOUS_TAG: ${{ steps.tags.outputs.previous_tag }}
89125
run: |
90-
git diff --name-status "${PREVIOUS_TAG}" "${CURRENT_TAG}" | sort > changed-files.txt
126+
git diff --name-status --no-renames "refs/tags/${PREVIOUS_TAG}" "refs/tags/${CURRENT_TAG}" | sort > ../changed-files.txt
91127
92-
FILE_COUNT=$( wc -l < changed-files.txt | tr -d ' ' )
128+
FILE_COUNT=$( wc -l < ../changed-files.txt | tr -d ' ' )
93129
94130
{
95131
echo "## Files Changed: \`${PREVIOUS_TAG}\` → \`${CURRENT_TAG}\`"
96132
echo ""
97133
echo "**${FILE_COUNT} file(s) changed** between \`${PREVIOUS_TAG}\` and \`${CURRENT_TAG}\`."
98134
echo ""
99-
echo "Status codes: \`A\` = Added, \`D\` = Deleted, \`M\` = Modified, \`R\` = Renamed."
135+
echo "Status codes: \`A\` = Added, \`D\` = Deleted, \`M\` = Modified."
100136
echo ""
101137
echo '```'
102-
cat changed-files.txt
138+
cat ../changed-files.txt
103139
echo '```'
104140
} >> "$GITHUB_STEP_SUMMARY"
105141
@@ -110,4 +146,4 @@ jobs:
110146
with:
111147
name: changed-files-${{ steps.tags.outputs.current_tag }}
112148
path: changed-files.txt
113-
if-no-files-found: error
149+
if-no-files-found: error

0 commit comments

Comments
 (0)