Commit 54a287bab33 for woocommerce

commit 54a287bab33682e0ff14dd74f7867a574da08663
Author: Jorge A. Torres <jorge.torres@automattic.com>
Date:   Thu Jul 30 20:29:35 2026 +0100

    Allow building non-release branches in the release ZIP workflow (#67078)

diff --git a/.github/workflows/release-build-zip-file.yml b/.github/workflows/release-build-zip-file.yml
index 1b31d68b1b3..28067fceebe 100644
--- a/.github/workflows/release-build-zip-file.yml
+++ b/.github/workflows/release-build-zip-file.yml
@@ -3,14 +3,10 @@ on:
   workflow_dispatch:
     inputs:
       branch:
-        description: 'Release branch (e.g. "release/9.8" or just "9.8").'
-        required: true
-      skip_verify:
-        description: 'Skip verification steps.'
-        type: boolean
+        description: 'Branch to build (e.g. "release/9.8" or "9.8"). Non-release branches just build a ZIP.'
         required: true
       create_github_release:
-        description: 'Create GitHub release.'
+        description: 'Create GitHub release (release branches only).'
         type: boolean
         default: false
   workflow_call:
@@ -48,6 +44,7 @@ jobs:
       contents: write # Required to fetch draft releases for some reason. See https://github.com/cli/cli/issues/9076#issuecomment-2146148572.
     outputs:
       branch: ${{ steps.normalize-branch.outputs.branch }}
+      is-release-branch: ${{ steps.normalize-branch.outputs.is-release-branch }}
     steps:
       - name: Normalize branch input
         id: normalize-branch
@@ -60,8 +57,26 @@ jobs:
           fi
           echo "branch=$branch" >> $GITHUB_OUTPUT

-      - run: |
-          echo "Building WooCommerce ZIP: branch=${{ steps.normalize-branch.outputs.branch }}, skip_verify=${{ inputs.skip_verify }}, create_github_release=${{ inputs.create_github_release }}"
+          is_release_branch=false
+          if [[ "$branch" == release/* ]]; then
+            is_release_branch=true
+          fi
+          echo "is-release-branch=$is_release_branch" >> $GITHUB_OUTPUT
+
+          # skip_verify only exists for workflow_call; manual dispatch always verifies before creating a release.
+          should_verify=false
+          if [ "$is_release_branch" = "true" ] && [ "${{ inputs.create_github_release }}" = "true" ] && [ "${{ inputs.skip_verify }}" != "true" ]; then
+            should_verify=true
+          fi
+          echo "should-verify=$should_verify" >> $GITHUB_OUTPUT
+
+      - env:
+          BRANCH: ${{ steps.normalize-branch.outputs.branch }}
+          IS_RELEASE_BRANCH: ${{ steps.normalize-branch.outputs.is-release-branch }}
+          SHOULD_VERIFY: ${{ steps.normalize-branch.outputs.should-verify }}
+          CREATE_GITHUB_RELEASE: ${{ inputs.create_github_release }}
+        run: |
+          echo "Building WooCommerce ZIP: branch=${BRANCH}, is_release_branch=${IS_RELEASE_BRANCH}, should_verify=${SHOULD_VERIFY}, create_github_release=${CREATE_GITHUB_RELEASE}"

       - name: Verify release branch
         env:
@@ -75,29 +90,31 @@ jobs:
       - name: Workflow checks
         env:
           BRANCH: ${{ steps.normalize-branch.outputs.branch }}
+          WORKFLOW_REF: ${{ github.ref }}
         run: |
           # No special checks when running as a reusable workflow.
           if [ "${{ ! contains( github.workflow_ref, 'release-build-zip-file.yml' ) }}" = "true" ]; then
             exit 0
           fi

-          # Write summary header.
-          options=""
-          [ "${{ inputs.skip_verify }}" = "true" ] && options="skipping verification"
-          [ "${{ inputs.create_github_release }}" = "true" ] && options="${options:+$options, }creating release"
-          [ -n "$options" ] && options=" ($options)"
-          echo "🔨 Building WooCommerce ZIP from \`${BRANCH}\`${options}." >> $GITHUB_STEP_SUMMARY
+          # Write summary header early, so it's visible even if a later check fails.
+          echo "🔨 Building WooCommerce ZIP from \`${BRANCH}\`." >> $GITHUB_STEP_SUMMARY

           # Must run from trunk.
-          if [ "${{ github.ref }}" != "refs/heads/trunk" ]; then
+          if [ "$WORKFLOW_REF" != "refs/heads/trunk" ]; then
             echo "::error::This workflow must be run from the 'trunk' branch. Enter the release branch as input."
             exit 1
           fi

-          # Can not skip verification for actual releases.
-          if [ "${{ inputs.create_github_release }}" = "true" ] && [ "${{ inputs.skip_verify }}" = "true" ]; then
-            echo "::error::Verification cannot be skipped when building for a release."
-            exit 1
+          # Non-release branches: just build, no other verification.
+          if [ "${{ steps.normalize-branch.outputs.is-release-branch }}" != "true" ]; then
+            echo "⚠️ Not a release branch — skipping checks, won't create a release." >> $GITHUB_STEP_SUMMARY
+            echo "::notice::'${BRANCH}' is not a release branch — skipping checks, won't create a release."
+            exit 0
+          fi
+
+          if [ "${{ inputs.create_github_release }}" = "true" ]; then
+            echo "Creating a GitHub release." >> $GITHUB_STEP_SUMMARY
           fi

         # Checkout trunk.
@@ -108,7 +125,7 @@ jobs:
           sparse-checkout: |
             /.github/workflows/scripts/release-check-db-updates.js
           sparse-checkout-cone-mode: false
-        if: ${{ ! inputs.skip_verify }}
+        if: ${{ steps.normalize-branch.outputs.should-verify == 'true' }}

         # Checkout branch.
       - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
@@ -119,11 +136,11 @@ jobs:
             /plugins/woocommerce/woocommerce.php
             /plugins/woocommerce/readme.txt
           sparse-checkout-cone-mode: false
-        if: ${{ ! inputs.skip_verify }}
+        if: ${{ steps.normalize-branch.outputs.should-verify == 'true' }}

       - name: 'Pre-build verification'
         id: pre-build-verification
-        if: ${{ ! inputs.skip_verify }}
+        if: ${{ steps.normalize-branch.outputs.should-verify == 'true' }}
         env:
           BRANCH: ${{ steps.normalize-branch.outputs.branch }}
           GH_TOKEN: ${{ github.token }}
@@ -201,7 +218,7 @@ jobs:
             echo "release_version=$branch_plugin_version" >> $GITHUB_OUTPUT

       - name: 'Pre-build verification: db updates'
-        if: ${{ ! inputs.skip_verify && ! contains( steps.pre-build-verification.outputs.release_version, '-dev' ) && ! contains( steps.pre-build-verification.outputs.release_version, '-beta.1' ) }}
+        if: ${{ steps.normalize-branch.outputs.should-verify == 'true' && ! contains( steps.pre-build-verification.outputs.release_version, '-dev' ) && ! contains( steps.pre-build-verification.outputs.release_version, '-beta.1' ) }}
         uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0
         with:
           script: |
@@ -262,8 +279,8 @@ jobs:
   create-release:
     name: Create GitHub release
     runs-on: ${{ github.repository == 'woocommerce/woocommerce' && fromJSON('{"group":"WooCommerce Release Checks"}') || 'ubuntu-latest' }}
-    needs: [ build ]
-    if: ${{ inputs.create_github_release }}
+    needs: [ verify, build ]
+    if: ${{ inputs.create_github_release && needs.verify.outputs.is-release-branch == 'true' }}
     permissions:
       contents: write
     steps: