7979 exit 1
8080 fi
8181
82- echo "VALIDATED_PLUGIN_VERSION=$PLUGIN_VERSION" >> $GITHUB_ENV
8382 echo "✅ Valid WordPress.org version: $PLUGIN_VERSION"
8483
8584 if ! git check-ref-format --allow-onelevel "$GIT_REF"; then
9695
9796 - name : Verify plugin file matches plugin version
9897 id : plugin_file_version
98+ env :
99+ PLUGIN_VERSION : ${{ inputs.PLUGIN_VERSION }}
99100 run : |
100101 set -euo pipefail
101102
@@ -128,29 +129,30 @@ jobs:
128129
129130 echo "README_VERSION=$README_VERSION" >> "$GITHUB_OUTPUT"
130131
131- if [ "$VALIDATED_PLUGIN_VERSION " != "$PLUGIN_FILE_VERSION" ]; then
132- echo "❌ Input version ($VALIDATED_PLUGIN_VERSION ) does not match $PLUGIN_FILE ($PLUGIN_FILE_VERSION)"
132+ if [ "$PLUGIN_VERSION " != "$PLUGIN_FILE_VERSION" ]; then
133+ echo "❌ Input version ($PLUGIN_VERSION ) does not match $PLUGIN_FILE ($PLUGIN_FILE_VERSION)"
133134 exit 1
134135 fi
135136
136- echo "✅ Version $VALIDATED_PLUGIN_VERSION is consistent with $PLUGIN_FILE"
137+ echo "✅ Version $PLUGIN_VERSION is consistent with $PLUGIN_FILE"
137138
138139 # During a trunk-only sync, Stable tag is expected to still point to an already-published
139140 # version, not PLUGIN_VERSION - that's checked against SVN's existing tags instead, once
140141 # the SVN repository is checked out (see "Verify readme points to an existing tag" below).
141142 - name : Verify readme matches plugin version
142143 if : inputs.UPDATE_TRUNK_ONLY == false
143144 env :
145+ PLUGIN_VERSION : ${{ inputs.PLUGIN_VERSION }}
144146 README_VERSION : ${{ steps.plugin_file_version.outputs.README_VERSION }}
145147 run : |
146148 set -euo pipefail
147149
148- if [ "$VALIDATED_PLUGIN_VERSION " != "$README_VERSION" ]; then
149- echo "❌ Input version ($VALIDATED_PLUGIN_VERSION ) does not match readme.txt Stable tag ($README_VERSION)"
150+ if [ "$PLUGIN_VERSION " != "$README_VERSION" ]; then
151+ echo "❌ Input version ($PLUGIN_VERSION ) does not match readme.txt Stable tag ($README_VERSION)"
150152 exit 1
151153 fi
152154
153- echo "✅ readme.txt Stable tag ($README_VERSION) matches version $VALIDATED_PLUGIN_VERSION "
155+ echo "✅ readme.txt Stable tag ($README_VERSION) matches version $PLUGIN_VERSION "
154156
155157 - name : Checkout SVN repository
156158 env :
@@ -254,9 +256,23 @@ jobs:
254256 cd "${SVN_REPO_ROOT}/trunk"
255257 svn status
256258
259+ - name : Copy trunk to new tag
260+ if : inputs.UPDATE_TRUNK_ONLY == false
261+ env :
262+ PLUGIN_VERSION : ${{ inputs.PLUGIN_VERSION }}
263+ run : |
264+ set -euo pipefail
265+
266+ cd "$SVN_REPO_ROOT"
267+
268+ # Copied locally so it commits together with trunk in a single transaction below.
269+ # WordPress.org's plugin SVN maintainer has explicitly discouraged splitting release commits
270+ svn copy trunk "tags/${PLUGIN_VERSION}"
271+
257272 - name : Commit changes to SVN repository
258273 if : inputs.DRY_RUN == false
259274 env :
275+ PLUGIN_VERSION : ${{ inputs.PLUGIN_VERSION }}
260276 SVN_USERNAME : ${{ secrets.SVN_USERNAME }}
261277 SVN_PASSWORD : ${{ secrets.SVN_PASSWORD }}
262278 run : |
@@ -265,42 +281,35 @@ jobs:
265281 [ -d "$SVN_REPO_ROOT" ] || { echo "❌ SVN_REPO_ROOT not found"; exit 1; }
266282 cd "$SVN_REPO_ROOT"
267283
284+ # Commit trunk and the new tag together (when tagging) so WordPress.org never sees
285+ # trunk pointing at a Stable tag that doesn't exist yet as a published tag.
286+ COMMIT_PATHS=(trunk)
287+ COMMIT_MESSAGE="Update trunk to version ${PLUGIN_VERSION}"
288+
289+ if [ "${{ inputs.UPDATE_TRUNK_ONLY }}" == "false" ]; then
290+ COMMIT_PATHS+=("tags/${PLUGIN_VERSION}")
291+ COMMIT_MESSAGE="Release version ${PLUGIN_VERSION}"
292+ fi
293+
268294 # Do not add -q to grep: it exits on the first match, SIGPIPE-ing svn status mid-write;
269295 # under pipefail that non-zero exit wins over grep's, which would wrongly report
270- # "No changes in trunk " and abort even when there are real changes to commit.
271- svn status trunk | grep '^[ADMR!~]' >/dev/null || { echo "❌ No changes in trunk "; exit 1; }
296+ # "No changes to commit " and abort even when there are real changes to commit.
297+ svn status "${COMMIT_PATHS[@]}" | grep '^[ADMR!~]' >/dev/null || { echo "❌ No changes to commit "; exit 1; }
272298
273299 # WordPress.org SVN doesn't support SSH keys or tokens.
274300 # Keeping credentials as step-level env vars with --no-auth-cache is the best available option.
275301 echo '🚀 Committing...'
276302
277- svn commit trunk \
278- --username "$SVN_USERNAME" \
279- --password "$SVN_PASSWORD" \
280- --no-auth-cache \
281- --non-interactive \
282- -m "Update trunk to version ${VALIDATED_PLUGIN_VERSION}"
283-
284- - name : Create a new tag
285- if : inputs.UPDATE_TRUNK_ONLY == false && inputs.DRY_RUN == false
286- env :
287- SVN_USERNAME : ${{ secrets.SVN_USERNAME }}
288- SVN_PASSWORD : ${{ secrets.SVN_PASSWORD }}
289- run : |
290- set -euo pipefail
291-
292- echo "🚀 Publishing version ${VALIDATED_PLUGIN_VERSION}"
293-
294- svn copy \
295- "https://plugins.svn.wordpress.org/${{ inputs.SVN_PLUGIN_SLUG }}/trunk" \
296- "https://plugins.svn.wordpress.org/${{ inputs.SVN_PLUGIN_SLUG }}/tags/${VALIDATED_PLUGIN_VERSION}" \
303+ svn commit "${COMMIT_PATHS[@]}" \
297304 --username "$SVN_USERNAME" \
298305 --password "$SVN_PASSWORD" \
299306 --no-auth-cache \
300307 --non-interactive \
301- -m "Tagging version ${VALIDATED_PLUGIN_VERSION} "
308+ -m "$COMMIT_MESSAGE "
302309
303- echo "✅ Version ${VALIDATED_PLUGIN_VERSION} was published to WordPress.org"
310+ if [ "${{ inputs.UPDATE_TRUNK_ONLY }}" == "false" ]; then
311+ echo "✅ Version ${PLUGIN_VERSION} was published to WordPress.org"
312+ fi
304313
305314 - name : Compress and upload trunk contents as an artifact
306315 if : inputs.DRY_RUN == true
0 commit comments