From cdb72ae2668c1c521ea29d6d11b880105e378484 Mon Sep 17 00:00:00 2001 From: Jonathan Desrosiers <359867+desrosj@users.noreply.github.com> Date: Mon, 23 Feb 2026 21:03:31 -0500 Subject: [PATCH 01/28] Publish the built plugin zip. This adds a job to the Build Gutenberg Plugin Zip workflow that publishes the built zip to the GitHub Container Registry. --- .github/workflows/build-plugin-zip.yml | 44 +++++++++++++++++++++++++- 1 file changed, 43 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build-plugin-zip.yml b/.github/workflows/build-plugin-zip.yml index 8434f835c2514e..c94cd5cb00734c 100644 --- a/.github/workflows/build-plugin-zip.yml +++ b/.github/workflows/build-plugin-zip.yml @@ -4,7 +4,7 @@ on: pull_request: push: branches: - - trunk + - 'trunk' - 'release/**' - 'wp/**' workflow_dispatch: @@ -241,6 +241,48 @@ jobs: name: release-notes path: ./release-notes.txt + # Publishes the built plugin zip file to the GitHub Container registry. + publish-to-container-registry: + name: Publish to GitHub Container Registry + runs-on: 'ubuntu-24.04' + needs: ['bump-version', 'build'] + permissions: + contents: read + packages: write + if: | + needs.build.outputs.job_status == 'success' + + steps: + - name: Download build artifact + uses: actions/download-artifact@37930b1c2abaa49bbe596cd826c3c89aef350131 # v7.0.0 + with: + name: gutenberg-plugin + + # Noting the hash helps keep track of the commit the zip was built from. + - name: Add a file for tracking the SHA value used. + run: echo "${{ github.sha }}" > .gutenberg-hash + + - name: Include the new file in the zip + run: zip gutenberg.zip .gutenberg-hash + + - name: Login to GitHub Container Registry + uses: docker/login-action@c94ce9fb468520275223c153574b00df6fe4bcc9 # v3.7.0 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Setup ORAS + uses: oras-project/setup-oras@22ce207df3b08e061f537244349aac6ae1d214f6 # v1.2.4 + + - name: Push built plugin ZIP file to GitHub Container Registry + run: | + oras push "ghcr.io/${{ github.repository }}/gutenberg-build:${{ github.sha }}" \ + "gutenberg.zip:application/zip" \ + --annotation "org.opencontainers.image.description=Gutenberg plugin build for commit ${{ github.sha }}" \ + --annotation "org.opencontainers.image.source=https://github.com/${{ github.repository }}" \ + --annotation "org.opencontainers.image.revision=${{ github.sha }}" + revert-version-bump: name: Revert version bump if build failed needs: [bump-version, build] From d7def7665e18a41b7c02b33d6ed15395947b1f62 Mon Sep 17 00:00:00 2001 From: Jonathan Desrosiers <359867+desrosj@users.noreply.github.com> Date: Fri, 6 Mar 2026 09:20:33 -0500 Subject: [PATCH 02/28] `always()` check is necessary. --- .github/workflows/build-plugin-zip.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/build-plugin-zip.yml b/.github/workflows/build-plugin-zip.yml index c94cd5cb00734c..ea3e65f07aa015 100644 --- a/.github/workflows/build-plugin-zip.yml +++ b/.github/workflows/build-plugin-zip.yml @@ -250,6 +250,7 @@ jobs: contents: read packages: write if: | + always() && needs.build.outputs.job_status == 'success' steps: From 3f8706d2aa4d1fc53a433bf9e96b3544cbc4dcc0 Mon Sep 17 00:00:00 2001 From: Jonathan Desrosiers <359867+desrosj@users.noreply.github.com> Date: Mon, 23 Feb 2026 21:23:35 -0500 Subject: [PATCH 03/28] Do not attempt to publish to GHCR in forks. --- .github/workflows/build-plugin-zip.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build-plugin-zip.yml b/.github/workflows/build-plugin-zip.yml index ea3e65f07aa015..9dd4139046a7f2 100644 --- a/.github/workflows/build-plugin-zip.yml +++ b/.github/workflows/build-plugin-zip.yml @@ -251,7 +251,8 @@ jobs: packages: write if: | always() && - needs.build.outputs.job_status == 'success' + needs.build.outputs.job_status == 'success' && + github.repository == 'WordPress/gutenberg' steps: - name: Download build artifact From 1679a20827b860c0ca9deeb3fef1d758d946a866 Mon Sep 17 00:00:00 2001 From: Jonathan Desrosiers <359867+desrosj@users.noreply.github.com> Date: Mon, 23 Feb 2026 21:24:40 -0500 Subject: [PATCH 04/28] Hardcode the org/repository. The organization and repository names cannot have capital letters. Since the conditionals ensure the job only runs in the WordPress/gutenberg repository, this value can be safely hard-coded. --- .github/workflows/build-plugin-zip.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build-plugin-zip.yml b/.github/workflows/build-plugin-zip.yml index 9dd4139046a7f2..8f90ff472abe6f 100644 --- a/.github/workflows/build-plugin-zip.yml +++ b/.github/workflows/build-plugin-zip.yml @@ -277,9 +277,11 @@ jobs: - name: Setup ORAS uses: oras-project/setup-oras@22ce207df3b08e061f537244349aac6ae1d214f6 # v1.2.4 + # The owner/repository is hard-coded here because capital letters are not allowed. + # See https://github.com/orgs/community/discussions/27086 for more info. - name: Push built plugin ZIP file to GitHub Container Registry run: | - oras push "ghcr.io/${{ github.repository }}/gutenberg-build:${{ github.sha }}" \ + oras push "ghcr.io/wordpress/gutenberg/gutenberg-build:${{ github.sha }}" \ "gutenberg.zip:application/zip" \ --annotation "org.opencontainers.image.description=Gutenberg plugin build for commit ${{ github.sha }}" \ --annotation "org.opencontainers.image.source=https://github.com/${{ github.repository }}" \ From 7a2316ebbb8ca16aabcee6c80f2f9f32ceb971d3 Mon Sep 17 00:00:00 2001 From: Jonathan Desrosiers <359867+desrosj@users.noreply.github.com> Date: Wed, 25 Feb 2026 14:26:02 -0500 Subject: [PATCH 05/28] Prepare a plugin artifact for `wordpress-develop` Because the `wp-build` package performs some substitutions, the script needs to be run with `IS_GUTENBERG_PLUGIN` set to `false` an `IS_WORDPRESS_CORE` set to `true`. --- .github/workflows/build-plugin-zip.yml | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build-plugin-zip.yml b/.github/workflows/build-plugin-zip.yml index 8f90ff472abe6f..36fd40724f4c0d 100644 --- a/.github/workflows/build-plugin-zip.yml +++ b/.github/workflows/build-plugin-zip.yml @@ -190,6 +190,15 @@ jobs: github.event_name == 'workflow_dispatch' || github.repository == 'WordPress/gutenberg' ) + strategy: + matrix: + IS_GUTENBERG_PLUGIN: [true] + IS_WORDPREESS_CORE: [false] + + include: + - IS_GUTENBERG_PLUGIN: [false] + IS_WORDPRESS_CORE: [true] + outputs: job_status: ${{ job.status }} @@ -211,11 +220,13 @@ jobs: run: ./bin/build-plugin-zip.sh env: NO_CHECKS: 'true' + IS_GUTENBERG_PLUGIN: ${{ matrix.IS_GUTENBERG_PLUGIN }} + IS_WORDPRESS_CORE: ${{ matrix.IS_WORDPRESS_CORE }} - name: Upload artifact uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0 with: - name: gutenberg-plugin + name: gutenberg-${{ matrix.IS_WORDPREESS_CORE && 'wordpress-develop' || 'plugin' }} path: ./gutenberg.zip - name: Build release notes draft @@ -258,7 +269,7 @@ jobs: - name: Download build artifact uses: actions/download-artifact@37930b1c2abaa49bbe596cd826c3c89aef350131 # v7.0.0 with: - name: gutenberg-plugin + name: gutenberg-wordpress-develop # Noting the hash helps keep track of the commit the zip was built from. - name: Add a file for tracking the SHA value used. From 7904fda9046fa04fdcb3b03949a0c5770a153860 Mon Sep 17 00:00:00 2001 From: Jonathan Desrosiers <359867+desrosj@users.noreply.github.com> Date: Wed, 25 Feb 2026 14:31:31 -0500 Subject: [PATCH 06/28] # This is a combination of 6 commits. # This is the 1st commit message: Publish the built plugin zip. This adds a job to the Build Gutenberg Plugin Zip workflow that publishes the built zip to the GitHub Container Registry. # This is the commit message #2: `always()` check is necessary. # This is the commit message #3: Don't use arrays for `include` combinations. # This is the commit message #4: Adjust job names so it's clear what's being done. This ensures the "Build Release Artifact" name is preserved when the assets are built for the Gutenberg plugin because that is a check that is required to be passing before a merge is allowed. # This is the commit message #5: Correct typo in environment variable. # This is the commit message #6: One more typo fix. --- .github/workflows/build-plugin-zip.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/build-plugin-zip.yml b/.github/workflows/build-plugin-zip.yml index 36fd40724f4c0d..7dded36395d3f9 100644 --- a/.github/workflows/build-plugin-zip.yml +++ b/.github/workflows/build-plugin-zip.yml @@ -179,7 +179,7 @@ jobs: fi build: - name: Build Release Artifact + name: ${{ matrix.IS_WORDPRESS_CORE && 'Build assets for wordpress-develop' || 'Build Release Artifact' }} runs-on: 'ubuntu-24.04' permissions: contents: read @@ -193,11 +193,11 @@ jobs: strategy: matrix: IS_GUTENBERG_PLUGIN: [true] - IS_WORDPREESS_CORE: [false] + IS_WORDPRESS_CORE: [false] include: - - IS_GUTENBERG_PLUGIN: [false] - IS_WORDPRESS_CORE: [true] + - IS_GUTENBERG_PLUGIN: false + IS_WORDPRESS_CORE: true outputs: job_status: ${{ job.status }} @@ -226,7 +226,7 @@ jobs: - name: Upload artifact uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0 with: - name: gutenberg-${{ matrix.IS_WORDPREESS_CORE && 'wordpress-develop' || 'plugin' }} + name: gutenberg-${{ matrix.IS_WORDPRESS_CORE && 'wordpress-develop' || 'plugin' }} path: ./gutenberg.zip - name: Build release notes draft From a3622f0adb4d19fa46eb57fff5ef84be082446cf Mon Sep 17 00:00:00 2001 From: Jonathan Desrosiers <359867+desrosj@users.noreply.github.com> Date: Fri, 6 Mar 2026 09:26:06 -0500 Subject: [PATCH 07/28] Publish the built plugin zip. This adds a job to the Build Gutenberg Plugin Zip workflow that publishes the built zip to the GitHub Container Registry. --- .github/workflows/build-plugin-zip.yml | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/.github/workflows/build-plugin-zip.yml b/.github/workflows/build-plugin-zip.yml index 7dded36395d3f9..fc96ca64c99705 100644 --- a/.github/workflows/build-plugin-zip.yml +++ b/.github/workflows/build-plugin-zip.yml @@ -192,12 +192,12 @@ jobs: ) strategy: matrix: - IS_GUTENBERG_PLUGIN: [true] - IS_WORDPRESS_CORE: [false] + IS_GUTENBERG_PLUGIN: ['true'] + IS_WORDPRESS_CORE: ['false'] include: - - IS_GUTENBERG_PLUGIN: false - IS_WORDPRESS_CORE: true + - IS_GUTENBERG_PLUGIN: 'false' + IS_WORDPRESS_CORE: 'true' outputs: job_status: ${{ job.status }} @@ -222,6 +222,7 @@ jobs: NO_CHECKS: 'true' IS_GUTENBERG_PLUGIN: ${{ matrix.IS_GUTENBERG_PLUGIN }} IS_WORDPRESS_CORE: ${{ matrix.IS_WORDPRESS_CORE }} + WP_PLUGIN_NAME: ${{ matrix.IS_WORDPRESS_CORE && 'wp' || 'gutenberg' }} - name: Upload artifact uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0 From 27e5999688e2e8f5ba8e07f730e7e49724c29d77 Mon Sep 17 00:00:00 2001 From: Jonathan Desrosiers <359867+desrosj@users.noreply.github.com> Date: Wed, 25 Feb 2026 14:53:59 -0500 Subject: [PATCH 08/28] # This is a combination of 5 commits. # This is the 1st commit message: Change the package name to be more specific. # This is the commit message #2: Change the package name on GHCR. Even though it's nested under the `gutenberg` repository, `wordpress-develop-build` could be confusing. # This is the commit message #3: Correct other relevant conditionals. # This is the commit message #4: Workflow file can be simplified now. With better type casting to avoid truthy false values, the workflow can be less cautious. # This is the commit message #5: Fix one missed conditional. --- .github/workflows/build-plugin-zip.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/build-plugin-zip.yml b/.github/workflows/build-plugin-zip.yml index fc96ca64c99705..f3bd8eef0c88d2 100644 --- a/.github/workflows/build-plugin-zip.yml +++ b/.github/workflows/build-plugin-zip.yml @@ -192,12 +192,12 @@ jobs: ) strategy: matrix: - IS_GUTENBERG_PLUGIN: ['true'] - IS_WORDPRESS_CORE: ['false'] + IS_GUTENBERG_PLUGIN: [true] + IS_WORDPRESS_CORE: [false] include: - - IS_GUTENBERG_PLUGIN: 'false' - IS_WORDPRESS_CORE: 'true' + - IS_GUTENBERG_PLUGIN: false + IS_WORDPRESS_CORE: true outputs: job_status: ${{ job.status }} @@ -293,7 +293,7 @@ jobs: # See https://github.com/orgs/community/discussions/27086 for more info. - name: Push built plugin ZIP file to GitHub Container Registry run: | - oras push "ghcr.io/wordpress/gutenberg/gutenberg-build:${{ github.sha }}" \ + oras push "ghcr.io/wordpress/gutenberg/gutenberg-wp-develop-build:${{ github.sha }}" \ "gutenberg.zip:application/zip" \ --annotation "org.opencontainers.image.description=Gutenberg plugin build for commit ${{ github.sha }}" \ --annotation "org.opencontainers.image.source=https://github.com/${{ github.repository }}" \ From afb6210e16dce7190032a017f71bd4306f2975ad Mon Sep 17 00:00:00 2001 From: Jonathan Desrosiers <359867+desrosj@users.noreply.github.com> Date: Fri, 6 Mar 2026 09:28:24 -0500 Subject: [PATCH 09/28] Make the package name more specific. Co-Authored-By: Dennis Snell --- .github/workflows/build-plugin-zip.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-plugin-zip.yml b/.github/workflows/build-plugin-zip.yml index f3bd8eef0c88d2..e2c1c2a32104f8 100644 --- a/.github/workflows/build-plugin-zip.yml +++ b/.github/workflows/build-plugin-zip.yml @@ -289,7 +289,7 @@ jobs: - name: Setup ORAS uses: oras-project/setup-oras@22ce207df3b08e061f537244349aac6ae1d214f6 # v1.2.4 - # The owner/repository is hard-coded here because capital letters are not allowed. + # Container Registry. The organization name is WordPress, so ${{ github.repository }} causes an error. # See https://github.com/orgs/community/discussions/27086 for more info. - name: Push built plugin ZIP file to GitHub Container Registry run: | From fbb61e3cde6a598241f7bfa1a73dea8220e27f3d Mon Sep 17 00:00:00 2001 From: Jonathan Desrosiers <359867+desrosj@users.noreply.github.com> Date: Thu, 26 Feb 2026 11:44:07 -0500 Subject: [PATCH 10/28] Allow plugin name to be overridden. This allows the plugin name setting to be overridden more easily so that GitHub Actions can change the behavior of the build package. --- package.json | 4 ++-- packages/wp-build/lib/php-generator.mjs | 3 +-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/package.json b/package.json index 4d5dd4e67e3022..318c6f302f0d58 100644 --- a/package.json +++ b/package.json @@ -19,7 +19,6 @@ "npm": ">=10.2.3" }, "wpPlugin": { - "name": "gutenberg", "scriptGlobal": "wp", "packageNamespace": "wordpress", "handlePrefix": "wp", @@ -37,7 +36,8 @@ ] }, "config": { - "IS_GUTENBERG_PLUGIN": true + "IS_GUTENBERG_PLUGIN": true, + "WP_PLUGIN_NAME": "gutenberg" }, "devDependencies": { "@apidevtools/json-schema-ref-parser": "11.6.4", diff --git a/packages/wp-build/lib/php-generator.mjs b/packages/wp-build/lib/php-generator.mjs index 0a781cdffa9259..7f8d5f8bcce8ca 100644 --- a/packages/wp-build/lib/php-generator.mjs +++ b/packages/wp-build/lib/php-generator.mjs @@ -27,8 +27,7 @@ export async function getPhpReplacements( rootDir, baseUrlExpression ) { throw new Error( 'Could not read root package.json' ); } - // @ts-expect-error specific override to package.json - const name = rootPackageJson.wpPlugin?.name || 'gutenberg'; + const name = process.env.npm_package_config_WP_PLUGIN_NAME || 'gutenberg'; const version = rootPackageJson.version; return { From 521eb9ca0a48a280da8414b352e5cf74c5950aa7 Mon Sep 17 00:00:00 2001 From: Jonathan Desrosiers <359867+desrosj@users.noreply.github.com> Date: Fri, 6 Mar 2026 09:32:09 -0500 Subject: [PATCH 11/28] Allow plugin name to be overridden. This allows the plugin name setting to be overridden more easily so that GitHub Actions can change the behavior of the build package. --- packages/wp-build/lib/php-generator.mjs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/packages/wp-build/lib/php-generator.mjs b/packages/wp-build/lib/php-generator.mjs index 7f8d5f8bcce8ca..462bd0ccd04a47 100644 --- a/packages/wp-build/lib/php-generator.mjs +++ b/packages/wp-build/lib/php-generator.mjs @@ -27,7 +27,12 @@ export async function getPhpReplacements( rootDir, baseUrlExpression ) { throw new Error( 'Could not read root package.json' ); } - const name = process.env.npm_package_config_WP_PLUGIN_NAME || 'gutenberg'; + const name = + process.env.WP_PLUGIN_NAME ?? + process.env.npm_package_config_WP_PLUGIN_NAME ?? + // @ts-expect-error specific override to package.json + rootPackageJson.wpPlugin?.name ?? + 'gutenberg'; const version = rootPackageJson.version; return { From 1b2ce86502ab49512f21ef87bb57230f0ca87e93 Mon Sep 17 00:00:00 2001 From: Jonathan Desrosiers <359867+desrosj@users.noreply.github.com> Date: Fri, 6 Mar 2026 09:32:54 -0500 Subject: [PATCH 12/28] # This is a combination of 4 commits. # This is the 1st commit message: Allow plugin name to be overridden. This allows the plugin name setting to be overridden more easily so that GitHub Actions can change the behavior of the build package. # This is the commit message #2: Support `wpPlugin.name` without env variables # This is the commit message #3: Ensure boolean casting is more reliable. # This is the commit message #4: Remove debug line. --- package.json | 4 ++-- packages/wp-build/lib/build.mjs | 25 +++++++++++++++++++++++++ 2 files changed, 27 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 318c6f302f0d58..4d5dd4e67e3022 100644 --- a/package.json +++ b/package.json @@ -19,6 +19,7 @@ "npm": ">=10.2.3" }, "wpPlugin": { + "name": "gutenberg", "scriptGlobal": "wp", "packageNamespace": "wordpress", "handlePrefix": "wp", @@ -36,8 +37,7 @@ ] }, "config": { - "IS_GUTENBERG_PLUGIN": true, - "WP_PLUGIN_NAME": "gutenberg" + "IS_GUTENBERG_PLUGIN": true }, "devDependencies": { "@apidevtools/json-schema-ref-parser": "11.6.4", diff --git a/packages/wp-build/lib/build.mjs b/packages/wp-build/lib/build.mjs index 17b3f230db2eed..b90ac537effdd8 100755 --- a/packages/wp-build/lib/build.mjs +++ b/packages/wp-build/lib/build.mjs @@ -113,12 +113,31 @@ const HANDLE_PREFIX = WP_PLUGIN_CONFIG.handlePrefix || PACKAGE_NAMESPACE; const EXTERNAL_NAMESPACES = WP_PLUGIN_CONFIG.externalNamespaces || {}; const PAGES = WP_PLUGIN_CONFIG.pages || []; +const toBool = (value) => { + if (value === undefined) return undefined; + if (typeof value === 'boolean') return value; + return value === 'true'; +}; + const baseDefine = { 'globalThis.IS_GUTENBERG_PLUGIN': JSON.stringify( +<<<<<<< HEAD Boolean( process.env.npm_package_config_IS_GUTENBERG_PLUGIN ) ), 'globalThis.IS_WORDPRESS_CORE': JSON.stringify( Boolean( process.env.npm_package_config_IS_WORDPRESS_CORE ) +======= + Boolean( + toBool(process.env.IS_GUTENBERG_PLUGIN) ?? + toBool(process.env.npm_package_config_IS_GUTENBERG_PLUGIN) + ) + ), + 'globalThis.IS_WORDPRESS_CORE': JSON.stringify( + Boolean( + toBool(process.env.IS_WORDPRESS_CORE) ?? + toBool(process.env.npm_package_config_IS_WORDPRESS_CORE) + ) +>>>>>>> eba463549f1 (Ensure boolean casting is more reliable.) ), }; const getDefine = ( scriptDebug ) => ( { @@ -2142,7 +2161,13 @@ async function main() { }, 'base-url': { type: 'string', +<<<<<<< HEAD default: 'plugin_dir_url( __FILE__ )', +======= + default: toBool( process.env.IS_WORDPRESS_CORE ) + ? 'includes_url( \'build/\' )' + : 'plugin_dir_url( __FILE__ )', +>>>>>>> eba463549f1 (Ensure boolean casting is more reliable.) }, }, strict: false, From 3217d23d4d54a6b573b14e3d6ac5573ad12aa860 Mon Sep 17 00:00:00 2001 From: Jonathan Desrosiers <359867+desrosj@users.noreply.github.com> Date: Fri, 6 Mar 2026 09:36:53 -0500 Subject: [PATCH 13/28] Allow plugin name to be overridden. This allows the plugin name setting to be overridden more easily so that GitHub Actions can change the behavior of the build package. --- packages/wp-build/lib/build.mjs | 40 ++++++++++++++++----------------- 1 file changed, 19 insertions(+), 21 deletions(-) diff --git a/packages/wp-build/lib/build.mjs b/packages/wp-build/lib/build.mjs index b90ac537effdd8..ff58cc456452af 100755 --- a/packages/wp-build/lib/build.mjs +++ b/packages/wp-build/lib/build.mjs @@ -113,31 +113,33 @@ const HANDLE_PREFIX = WP_PLUGIN_CONFIG.handlePrefix || PACKAGE_NAMESPACE; const EXTERNAL_NAMESPACES = WP_PLUGIN_CONFIG.externalNamespaces || {}; const PAGES = WP_PLUGIN_CONFIG.pages || []; -const toBool = (value) => { - if (value === undefined) return undefined; - if (typeof value === 'boolean') return value; +/** + * Reliably casts a value into a boolean. + * + * This helps to avoid scenarios where falsey string values such as false or 0 + * are "truthy" and incorrectly typecast to Boolean true. + * + * @param {string|boolean|undefined} value The value to cast. + * @return {boolean} The typecast value. + */ +const castBool = ( value ) => { + if ( typeof value === 'boolean' ) { + return value; + } return value === 'true'; }; const baseDefine = { 'globalThis.IS_GUTENBERG_PLUGIN': JSON.stringify( -<<<<<<< HEAD - Boolean( process.env.npm_package_config_IS_GUTENBERG_PLUGIN ) - ), - 'globalThis.IS_WORDPRESS_CORE': JSON.stringify( - Boolean( process.env.npm_package_config_IS_WORDPRESS_CORE ) -======= - Boolean( - toBool(process.env.IS_GUTENBERG_PLUGIN) ?? - toBool(process.env.npm_package_config_IS_GUTENBERG_PLUGIN) + castBool( process.env.IS_GUTENBERG_PLUGIN ) ?? + castBool( process.env.npm_package_config_IS_GUTENBERG_PLUGIN ) ) ), 'globalThis.IS_WORDPRESS_CORE': JSON.stringify( Boolean( - toBool(process.env.IS_WORDPRESS_CORE) ?? - toBool(process.env.npm_package_config_IS_WORDPRESS_CORE) + castBool( process.env.IS_WORDPRESS_CORE ) ?? + castBool( process.env.npm_package_config_IS_WORDPRESS_CORE ) ) ->>>>>>> eba463549f1 (Ensure boolean casting is more reliable.) ), }; const getDefine = ( scriptDebug ) => ( { @@ -2161,13 +2163,9 @@ async function main() { }, 'base-url': { type: 'string', -<<<<<<< HEAD - default: 'plugin_dir_url( __FILE__ )', -======= - default: toBool( process.env.IS_WORDPRESS_CORE ) - ? 'includes_url( \'build/\' )' + default: castBool( process.env.IS_WORDPRESS_CORE ) + ? "includes_url( 'build/' )" : 'plugin_dir_url( __FILE__ )', ->>>>>>> eba463549f1 (Ensure boolean casting is more reliable.) }, }, strict: false, From 9aae9313950e13f0030d1719fa8264d72aca447d Mon Sep 17 00:00:00 2001 From: Jonathan Desrosiers <359867+desrosj@users.noreply.github.com> Date: Fri, 6 Mar 2026 09:39:15 -0500 Subject: [PATCH 14/28] Make the default `base-url` value context aware. --- packages/wp-build/lib/build.mjs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/wp-build/lib/build.mjs b/packages/wp-build/lib/build.mjs index ff58cc456452af..68f28086dc8398 100755 --- a/packages/wp-build/lib/build.mjs +++ b/packages/wp-build/lib/build.mjs @@ -2164,7 +2164,7 @@ async function main() { 'base-url': { type: 'string', default: castBool( process.env.IS_WORDPRESS_CORE ) - ? "includes_url( 'build/' )" + ? 'includes_url( \'build/\' )' : 'plugin_dir_url( __FILE__ )', }, }, From c2ac0601a975aeda1e7be0a96ce7ae3607bbca56 Mon Sep 17 00:00:00 2001 From: Jonathan Desrosiers <359867+desrosj@users.noreply.github.com> Date: Fri, 6 Mar 2026 09:43:00 -0500 Subject: [PATCH 15/28] Allow relevant values to be overridden more easily --- packages/wp-build/lib/php-generator.mjs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/packages/wp-build/lib/php-generator.mjs b/packages/wp-build/lib/php-generator.mjs index 462bd0ccd04a47..81d1372e966167 100644 --- a/packages/wp-build/lib/php-generator.mjs +++ b/packages/wp-build/lib/php-generator.mjs @@ -30,8 +30,11 @@ export async function getPhpReplacements( rootDir, baseUrlExpression ) { const name = process.env.WP_PLUGIN_NAME ?? process.env.npm_package_config_WP_PLUGIN_NAME ?? +<<<<<<< HEAD // @ts-expect-error specific override to package.json rootPackageJson.wpPlugin?.name ?? +======= +>>>>>>> f25c45cd54e (Allow relevant values to be overridden more easily) 'gutenberg'; const version = rootPackageJson.version; From e0e94852db3cba8769bd8885c31cf6cf6a58b1f7 Mon Sep 17 00:00:00 2001 From: Jonathan Desrosiers <359867+desrosj@users.noreply.github.com> Date: Fri, 27 Feb 2026 14:53:51 -0500 Subject: [PATCH 16/28] Skip PHP transforms when building for WP Core. --- packages/wp-build/lib/build.mjs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/packages/wp-build/lib/build.mjs b/packages/wp-build/lib/build.mjs index 68f28086dc8398..7f45bf62c72dcd 100755 --- a/packages/wp-build/lib/build.mjs +++ b/packages/wp-build/lib/build.mjs @@ -336,6 +336,11 @@ function transformPhpContent( content, transforms ) { content = content.toString(); + // Skip any transforms when building for WordPress Core. + if ( toBool( process.env.IS_WORDPRESS_CORE ) ) { + return content; + } + if ( prefixFunctions.length ) { content = content.replace( new RegExp( prefixFunctions.join( '|' ), 'g' ), From a811c3d907ed0d91551d8a844a58a109da389390 Mon Sep 17 00:00:00 2001 From: Jonathan Desrosiers <359867+desrosj@users.noreply.github.com> Date: Fri, 27 Feb 2026 23:08:08 -0500 Subject: [PATCH 17/28] Document environment variable in README. --- packages/wp-build/README.md | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/packages/wp-build/README.md b/packages/wp-build/README.md index cf05da43cbdeb2..c844ee488a0888 100644 --- a/packages/wp-build/README.md +++ b/packages/wp-build/README.md @@ -526,6 +526,40 @@ The build system generates: The boot package in Gutenberg will automatically use these routes and make them available. +## Using Environment Variables to Control Behavior + +In some scenarios, it can be helpful to change how the build script works through environment variables. This is particularly useful within CI/CD workflows. + +The following environment variables can be used to override `wpPlugin` properties. + +| Environment Variable | `wpPlugin` Property | +|--------------------------|---------------------| +| `WP_PLUGIN_NAME` | `name` | + +### Example + +Here is an example job for a GitHub Actions workflow file that uses environment variables to change behavior: + +```yaml +build: + name: Build ${{ matrix.plugin-name }} plugin + runs-on: 'ubuntu-latest' + permissions: + contents: read + + strategy: + matrix: + plugin-name: [ 'my-plugin', 'my-plugin-premium' ] + + steps: + # Perform other steps to prepare for buildling (checkout repository, install dependencies, etc.) + + - name: Build plugin + run: npm run build + env: + WP_PLUGIN_NAME: ${{ matrix.plugin-name }} +``` + ## Contributing to this package This is an individual package that's part of the Gutenberg project. The project is organized as a monorepo. It's made up of multiple self-contained software packages, each with a specific purpose. From 51862198eb95f847954c4fd1b4893ab85cfb5a3d Mon Sep 17 00:00:00 2001 From: Jonathan Desrosiers <359867+desrosj@users.noreply.github.com> Date: Fri, 6 Mar 2026 09:47:57 -0500 Subject: [PATCH 18/28] Improve utility function name and inline docs. --- .github/workflows/build-plugin-zip.yml | 1 + packages/wp-build/lib/build.mjs | 18 ++++++++++-------- packages/wp-build/lib/php-generator.mjs | 3 --- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/.github/workflows/build-plugin-zip.yml b/.github/workflows/build-plugin-zip.yml index e2c1c2a32104f8..f6575bd9a1885e 100644 --- a/.github/workflows/build-plugin-zip.yml +++ b/.github/workflows/build-plugin-zip.yml @@ -289,6 +289,7 @@ jobs: - name: Setup ORAS uses: oras-project/setup-oras@22ce207df3b08e061f537244349aac6ae1d214f6 # v1.2.4 + # The owner/repository is hard-coded because capital letters are not allowed when publishing to GitHub # Container Registry. The organization name is WordPress, so ${{ github.repository }} causes an error. # See https://github.com/orgs/community/discussions/27086 for more info. - name: Push built plugin ZIP file to GitHub Container Registry diff --git a/packages/wp-build/lib/build.mjs b/packages/wp-build/lib/build.mjs index 7f45bf62c72dcd..0303b9fbcd08e1 100755 --- a/packages/wp-build/lib/build.mjs +++ b/packages/wp-build/lib/build.mjs @@ -120,13 +120,10 @@ const PAGES = WP_PLUGIN_CONFIG.pages || []; * are "truthy" and incorrectly typecast to Boolean true. * * @param {string|boolean|undefined} value The value to cast. - * @return {boolean} The typecast value. + * @returns {boolean} The typecast value. */ -const castBool = ( value ) => { - if ( typeof value === 'boolean' ) { - return value; - } - return value === 'true'; +const castBool = (value) => { + if (typeof value === 'boolean') return value; }; const baseDefine = { @@ -336,8 +333,13 @@ function transformPhpContent( content, transforms ) { content = content.toString(); - // Skip any transforms when building for WordPress Core. - if ( toBool( process.env.IS_WORDPRESS_CORE ) ) { + /* + * Transforms are used to modify PHP files that are committed to version + * control in their wordpress-develop state (`wp_` function prefixes, `WP_` + * class prefixes, etc.). When building for WordPress Core, it's not + * necessary to perform these steps. + */ + if ( castBool( process.env.IS_WORDPRESS_CORE ) ) { return content; } diff --git a/packages/wp-build/lib/php-generator.mjs b/packages/wp-build/lib/php-generator.mjs index 81d1372e966167..462bd0ccd04a47 100644 --- a/packages/wp-build/lib/php-generator.mjs +++ b/packages/wp-build/lib/php-generator.mjs @@ -30,11 +30,8 @@ export async function getPhpReplacements( rootDir, baseUrlExpression ) { const name = process.env.WP_PLUGIN_NAME ?? process.env.npm_package_config_WP_PLUGIN_NAME ?? -<<<<<<< HEAD // @ts-expect-error specific override to package.json rootPackageJson.wpPlugin?.name ?? -======= ->>>>>>> f25c45cd54e (Allow relevant values to be overridden more easily) 'gutenberg'; const version = rootPackageJson.version; From 9f6a64cf4a454d533a35b5065242b3cd7a992425 Mon Sep 17 00:00:00 2001 From: Jonathan Desrosiers <359867+desrosj@users.noreply.github.com> Date: Fri, 6 Mar 2026 09:50:13 -0500 Subject: [PATCH 19/28] Update CHANGELOG. --- packages/wp-build/CHANGELOG.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/packages/wp-build/CHANGELOG.md b/packages/wp-build/CHANGELOG.md index 19c3d4c3cfa323..cce91593d25e79 100644 --- a/packages/wp-build/CHANGELOG.md +++ b/packages/wp-build/CHANGELOG.md @@ -2,6 +2,12 @@ ## Unreleased +### Enhancements + +- Introduced the `WP_PLUGIN_NAME` environment variable for overriding `wpPlugin.name` ([#75844](https://github.com/WordPress/gutenberg/pull/75844)). +- Avoid unexpected results when typecasting `IS_GUTENBERG_PLUGIN` and `IS_WORDPRESS_CORE` values to Booleans ([#75844](https://github.com/WordPress/gutenberg/pull/75844)). +- Skip PHP transforms during builds when building for WordPress Core ([#75844](https://github.com/WordPress/gutenberg/pull/75844)). + ## 0.9.0 (2026-03-04) ## 0.8.0 (2026-02-18) From ee04ae623d6cca4cacf07d6ac907057b27f694c1 Mon Sep 17 00:00:00 2001 From: Jonathan Desrosiers <359867+desrosj@users.noreply.github.com> Date: Fri, 6 Mar 2026 09:52:27 -0500 Subject: [PATCH 20/28] Account for more truthy values in `castBool` --- packages/wp-build/lib/build.mjs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/packages/wp-build/lib/build.mjs b/packages/wp-build/lib/build.mjs index 0303b9fbcd08e1..b8eda11a668019 100755 --- a/packages/wp-build/lib/build.mjs +++ b/packages/wp-build/lib/build.mjs @@ -122,8 +122,11 @@ const PAGES = WP_PLUGIN_CONFIG.pages || []; * @param {string|boolean|undefined} value The value to cast. * @returns {boolean} The typecast value. */ -const castBool = (value) => { - if (typeof value === 'boolean') return value; +const castBool = ( value ) => { + if ( typeof value === 'boolean' ) { + return value; + } + return [ 'true', '1', 1 ].includes( value?.toLowerCase?.() ?? value ); }; const baseDefine = { From fcdd69b9f5475170118d60dd7860ea9e538e975c Mon Sep 17 00:00:00 2001 From: Jonathan Desrosiers <359867+desrosj@users.noreply.github.com> Date: Mon, 2 Mar 2026 14:27:05 -0500 Subject: [PATCH 21/28] Remove unrelated change. Co-Authored-By: Dennis Snell --- .github/workflows/build-plugin-zip.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-plugin-zip.yml b/.github/workflows/build-plugin-zip.yml index f6575bd9a1885e..c77cbbd83e0c69 100644 --- a/.github/workflows/build-plugin-zip.yml +++ b/.github/workflows/build-plugin-zip.yml @@ -4,7 +4,7 @@ on: pull_request: push: branches: - - 'trunk' + - trunk - 'release/**' - 'wp/**' workflow_dispatch: From d9ced680e34e0e7f31adc0d52c973f40cd3ae642 Mon Sep 17 00:00:00 2001 From: Jonathan Desrosiers <359867+desrosj@users.noreply.github.com> Date: Mon, 2 Mar 2026 14:33:38 -0500 Subject: [PATCH 22/28] Add a description to the ORAS step. Co-Authored-By: Dennis Snell --- .github/workflows/build-plugin-zip.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/build-plugin-zip.yml b/.github/workflows/build-plugin-zip.yml index c77cbbd83e0c69..3b87694612a96f 100644 --- a/.github/workflows/build-plugin-zip.yml +++ b/.github/workflows/build-plugin-zip.yml @@ -286,6 +286,8 @@ jobs: username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} + # OCI Registry As Storage (ORAS) provides a way to push and pull non-image, generic artifacts (zip files, + # for example) to container registries such as GitHub Container Registry. - name: Setup ORAS uses: oras-project/setup-oras@22ce207df3b08e061f537244349aac6ae1d214f6 # v1.2.4 From 8aa52bc215b2715151df64c4cc261402cc70f610 Mon Sep 17 00:00:00 2001 From: Jonathan Desrosiers <359867+desrosj@users.noreply.github.com> Date: Mon, 2 Mar 2026 15:32:37 -0500 Subject: [PATCH 23/28] Switch to using `.gz` over `.zip`. Co-Authored-By: Dennis Snell Push some debug code. Co-Authored-By: Dennis Snell Make corrections to new compression steps. Change directory to compress. Avoid `tar` writing to itself. Unzip GitHub artifact. Zip files are rezipped by upload-artifact. Relax repo specific rules Debugging. Adjust. More changes. Remove debug code. --- .github/workflows/build-plugin-zip.yml | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/.github/workflows/build-plugin-zip.yml b/.github/workflows/build-plugin-zip.yml index 3b87694612a96f..8a72190c052294 100644 --- a/.github/workflows/build-plugin-zip.yml +++ b/.github/workflows/build-plugin-zip.yml @@ -187,8 +187,7 @@ jobs: if: | always() && ( github.event_name == 'pull_request' || - github.event_name == 'workflow_dispatch' || - github.repository == 'WordPress/gutenberg' + github.event_name == 'workflow_dispatch' ) strategy: matrix: @@ -263,8 +262,7 @@ jobs: packages: write if: | always() && - needs.build.outputs.job_status == 'success' && - github.repository == 'WordPress/gutenberg' + needs.build.outputs.job_status == 'success' steps: - name: Download build artifact @@ -272,12 +270,15 @@ jobs: with: name: gutenberg-wordpress-develop + - name: Unzip zip artifact + run: unzip gutenberg.zip && rm gutenberg.zip + # Noting the hash helps keep track of the commit the zip was built from. - name: Add a file for tracking the SHA value used. run: echo "${{ github.sha }}" > .gutenberg-hash - - name: Include the new file in the zip - run: zip gutenberg.zip .gutenberg-hash + - name: Recompress as a .gz file + run: tar -czf ${{ runner.temp }}/gutenberg.tar.gz . && mv ${{ runner.temp }}/gutenberg.tar.gz . - name: Login to GitHub Container Registry uses: docker/login-action@c94ce9fb468520275223c153574b00df6fe4bcc9 # v3.7.0 @@ -286,7 +287,7 @@ jobs: username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} - # OCI Registry As Storage (ORAS) provides a way to push and pull non-image, generic artifacts (zip files, + # OCI Registry As Storage (ORAS) provides a way to push and pull non-image, generic artifacts (.gz files, # for example) to container registries such as GitHub Container Registry. - name: Setup ORAS uses: oras-project/setup-oras@22ce207df3b08e061f537244349aac6ae1d214f6 # v1.2.4 @@ -294,10 +295,10 @@ jobs: # The owner/repository is hard-coded because capital letters are not allowed when publishing to GitHub # Container Registry. The organization name is WordPress, so ${{ github.repository }} causes an error. # See https://github.com/orgs/community/discussions/27086 for more info. - - name: Push built plugin ZIP file to GitHub Container Registry + - name: Push built plugin .tar.gz file to GitHub Container Registry run: | oras push "ghcr.io/wordpress/gutenberg/gutenberg-wp-develop-build:${{ github.sha }}" \ - "gutenberg.zip:application/zip" \ + "gutenberg.tar.gz:application/gzip" \ --annotation "org.opencontainers.image.description=Gutenberg plugin build for commit ${{ github.sha }}" \ --annotation "org.opencontainers.image.source=https://github.com/${{ github.repository }}" \ --annotation "org.opencontainers.image.revision=${{ github.sha }}" From 387f52da6e177edadc3e1087e91555c8bebe75d6 Mon Sep 17 00:00:00 2001 From: Jonathan Desrosiers <359867+desrosj@users.noreply.github.com> Date: Fri, 6 Mar 2026 09:55:20 -0500 Subject: [PATCH 24/28] Improvements to the boolean casting function. Co-Authored-By: Dennis Snell --- packages/wp-build/lib/build.mjs | 38 +++++++++++++++++---------------- 1 file changed, 20 insertions(+), 18 deletions(-) diff --git a/packages/wp-build/lib/build.mjs b/packages/wp-build/lib/build.mjs index b8eda11a668019..5a6bd352cc5387 100755 --- a/packages/wp-build/lib/build.mjs +++ b/packages/wp-build/lib/build.mjs @@ -114,31 +114,33 @@ const EXTERNAL_NAMESPACES = WP_PLUGIN_CONFIG.externalNamespaces || {}; const PAGES = WP_PLUGIN_CONFIG.pages || []; /** - * Reliably casts a value into a boolean. + * Interprets a configuration value as a boolean, where `"true"` and `"1"` + * are considered true while all other values are false. * - * This helps to avoid scenarios where falsey string values such as false or 0 - * are "truthy" and incorrectly typecast to Boolean true. - * - * @param {string|boolean|undefined} value The value to cast. - * @returns {boolean} The typecast value. + * @param {string|undefined} value The configuration value to interpret. + * @return {boolean} Boolean interpretation of the given configuration value. */ -const castBool = ( value ) => { - if ( typeof value === 'boolean' ) { - return value; - } - return [ 'true', '1', 1 ].includes( value?.toLowerCase?.() ?? value ); +const boolConfigVal = ( value ) => { + return ( + value !== undefined && [ 'true', '1' ].includes( value.toLowerCase() ) + ); }; const baseDefine = { 'globalThis.IS_GUTENBERG_PLUGIN': JSON.stringify( - castBool( process.env.IS_GUTENBERG_PLUGIN ) ?? - castBool( process.env.npm_package_config_IS_GUTENBERG_PLUGIN ) + Boolean( + boolConfigVal( globalThis.IS_GUTENBERG_PLUGIN ) ?? + boolConfigVal( + process.env.npm_package_config_IS_GUTENBERG_PLUGIN + ) ) ), 'globalThis.IS_WORDPRESS_CORE': JSON.stringify( Boolean( - castBool( process.env.IS_WORDPRESS_CORE ) ?? - castBool( process.env.npm_package_config_IS_WORDPRESS_CORE ) + boolConfigVal( globalThis.IS_WORDPRESS_CORE ) ?? + boolConfigVal( + process.env.npm_package_config_IS_WORDPRESS_CORE + ) ) ), }; @@ -342,7 +344,7 @@ function transformPhpContent( content, transforms ) { * class prefixes, etc.). When building for WordPress Core, it's not * necessary to perform these steps. */ - if ( castBool( process.env.IS_WORDPRESS_CORE ) ) { + if ( boolConfigVal( globalThis.IS_WORDPRESS_CORE ) ) { return content; } @@ -2173,8 +2175,8 @@ async function main() { }, 'base-url': { type: 'string', - default: castBool( process.env.IS_WORDPRESS_CORE ) - ? 'includes_url( \'build/\' )' + default: boolConfigVal( globalThis.IS_WORDPRESS_CORE ) + ? "includes_url( 'build/' )" : 'plugin_dir_url( __FILE__ )', }, }, From 1bbed3c2f02ae27b3152a8bb3ba1b11f6d475f24 Mon Sep 17 00:00:00 2001 From: Jonathan Desrosiers <359867+desrosj@users.noreply.github.com> Date: Fri, 6 Mar 2026 10:31:45 -0500 Subject: [PATCH 25/28] Final coding standards fixes. --- .github/workflows/build-plugin-zip.yml | 2 +- packages/wp-build/.eslintrc.cjs | 6 ++++++ packages/wp-build/lib/build.mjs | 22 ++++++++-------------- 3 files changed, 15 insertions(+), 15 deletions(-) diff --git a/.github/workflows/build-plugin-zip.yml b/.github/workflows/build-plugin-zip.yml index 8a72190c052294..d98905dcd1a87f 100644 --- a/.github/workflows/build-plugin-zip.yml +++ b/.github/workflows/build-plugin-zip.yml @@ -292,7 +292,7 @@ jobs: - name: Setup ORAS uses: oras-project/setup-oras@22ce207df3b08e061f537244349aac6ae1d214f6 # v1.2.4 - # The owner/repository is hard-coded because capital letters are not allowed when publishing to GitHub + # The owner/repository is hard-coded because capital letters are not allowed when publishing to GitHub # Container Registry. The organization name is WordPress, so ${{ github.repository }} causes an error. # See https://github.com/orgs/community/discussions/27086 for more info. - name: Push built plugin .tar.gz file to GitHub Container Registry diff --git a/packages/wp-build/.eslintrc.cjs b/packages/wp-build/.eslintrc.cjs index ae9769b2365c13..535eca2c131a6e 100644 --- a/packages/wp-build/.eslintrc.cjs +++ b/packages/wp-build/.eslintrc.cjs @@ -4,5 +4,11 @@ module.exports = { rules: { // Console should be allowed in a build tool 'no-console': 'off', + /* + * These rules are designed for source files processed by esbuild, not for the build script itself, + * which runs directly in Node.js. + */ + '@wordpress/no-wp-process-env': 'off', + '@wordpress/wp-global-usage': 'off', }, }; diff --git a/packages/wp-build/lib/build.mjs b/packages/wp-build/lib/build.mjs index 5a6bd352cc5387..f9ae2697b0defa 100755 --- a/packages/wp-build/lib/build.mjs +++ b/packages/wp-build/lib/build.mjs @@ -128,20 +128,12 @@ const boolConfigVal = ( value ) => { const baseDefine = { 'globalThis.IS_GUTENBERG_PLUGIN': JSON.stringify( - Boolean( - boolConfigVal( globalThis.IS_GUTENBERG_PLUGIN ) ?? - boolConfigVal( - process.env.npm_package_config_IS_GUTENBERG_PLUGIN - ) - ) + boolConfigVal( process.env.IS_GUTENBERG_PLUGIN ) || + boolConfigVal( process.env.npm_package_config_IS_GUTENBERG_PLUGIN ) ), 'globalThis.IS_WORDPRESS_CORE': JSON.stringify( - Boolean( - boolConfigVal( globalThis.IS_WORDPRESS_CORE ) ?? - boolConfigVal( - process.env.npm_package_config_IS_WORDPRESS_CORE - ) - ) + boolConfigVal( process.env.IS_WORDPRESS_CORE ) || + boolConfigVal( process.env.npm_package_config_IS_WORDPRESS_CORE ) ), }; const getDefine = ( scriptDebug ) => ( { @@ -344,7 +336,7 @@ function transformPhpContent( content, transforms ) { * class prefixes, etc.). When building for WordPress Core, it's not * necessary to perform these steps. */ - if ( boolConfigVal( globalThis.IS_WORDPRESS_CORE ) ) { + if ( boolConfigVal( process.env.IS_WORDPRESS_CORE ) ) { return content; } @@ -2175,7 +2167,7 @@ async function main() { }, 'base-url': { type: 'string', - default: boolConfigVal( globalThis.IS_WORDPRESS_CORE ) + default: boolConfigVal( process.env.IS_WORDPRESS_CORE ) ? "includes_url( 'build/' )" : 'plugin_dir_url( __FILE__ )', }, @@ -2197,3 +2189,5 @@ main().catch( ( error ) => { console.error( '❌ Build failed:', error ); process.exit( 1 ); } ); + +/* eslint-enable @wordpress/no-wp-process-env, @wordpress/wp-global-usage */ From c201f843f73e29578fc9bd9d19a825cc6109d6cf Mon Sep 17 00:00:00 2001 From: Jonathan Desrosiers <359867+desrosj@users.noreply.github.com> Date: Fri, 6 Mar 2026 10:33:18 -0500 Subject: [PATCH 26/28] Remove stray unnecessary `eslint-enable`. --- packages/wp-build/lib/build.mjs | 2 -- 1 file changed, 2 deletions(-) diff --git a/packages/wp-build/lib/build.mjs b/packages/wp-build/lib/build.mjs index f9ae2697b0defa..c5ad3cbea9038b 100755 --- a/packages/wp-build/lib/build.mjs +++ b/packages/wp-build/lib/build.mjs @@ -2189,5 +2189,3 @@ main().catch( ( error ) => { console.error( '❌ Build failed:', error ); process.exit( 1 ); } ); - -/* eslint-enable @wordpress/no-wp-process-env, @wordpress/wp-global-usage */ From 9a1f7d8eb25747e83cfd17a09e679bc2bf1af3dc Mon Sep 17 00:00:00 2001 From: Jonathan Desrosiers <359867+desrosj@users.noreply.github.com> Date: Fri, 6 Mar 2026 23:11:28 -0500 Subject: [PATCH 27/28] Remove the `WP_PLUGIN_NAME` env variable. This eliminates an environment variable that's essentially only present to facilitate builds for `wordpress-develop`. --- .github/workflows/build-plugin-zip.yml | 5 +++- packages/wp-build/CHANGELOG.md | 1 - packages/wp-build/README.md | 34 ------------------------- packages/wp-build/lib/php-generator.mjs | 8 ++---- 4 files changed, 6 insertions(+), 42 deletions(-) diff --git a/.github/workflows/build-plugin-zip.yml b/.github/workflows/build-plugin-zip.yml index d98905dcd1a87f..ddf34c1bc797c1 100644 --- a/.github/workflows/build-plugin-zip.yml +++ b/.github/workflows/build-plugin-zip.yml @@ -215,13 +215,16 @@ jobs: node-version-file: '.nvmrc' check-latest: true + - name: Configure build for wordpress-develop + if: ${{ matrix.IS_WORDPRESS_CORE }} + run: jq --tab '.wpPlugin.name = "wp"' package.json > package.json.tmp && mv package.json.tmp package.json + - name: Build Gutenberg plugin ZIP file run: ./bin/build-plugin-zip.sh env: NO_CHECKS: 'true' IS_GUTENBERG_PLUGIN: ${{ matrix.IS_GUTENBERG_PLUGIN }} IS_WORDPRESS_CORE: ${{ matrix.IS_WORDPRESS_CORE }} - WP_PLUGIN_NAME: ${{ matrix.IS_WORDPRESS_CORE && 'wp' || 'gutenberg' }} - name: Upload artifact uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0 diff --git a/packages/wp-build/CHANGELOG.md b/packages/wp-build/CHANGELOG.md index cce91593d25e79..8a8f3f6eb44b8f 100644 --- a/packages/wp-build/CHANGELOG.md +++ b/packages/wp-build/CHANGELOG.md @@ -4,7 +4,6 @@ ### Enhancements -- Introduced the `WP_PLUGIN_NAME` environment variable for overriding `wpPlugin.name` ([#75844](https://github.com/WordPress/gutenberg/pull/75844)). - Avoid unexpected results when typecasting `IS_GUTENBERG_PLUGIN` and `IS_WORDPRESS_CORE` values to Booleans ([#75844](https://github.com/WordPress/gutenberg/pull/75844)). - Skip PHP transforms during builds when building for WordPress Core ([#75844](https://github.com/WordPress/gutenberg/pull/75844)). diff --git a/packages/wp-build/README.md b/packages/wp-build/README.md index c844ee488a0888..cf05da43cbdeb2 100644 --- a/packages/wp-build/README.md +++ b/packages/wp-build/README.md @@ -526,40 +526,6 @@ The build system generates: The boot package in Gutenberg will automatically use these routes and make them available. -## Using Environment Variables to Control Behavior - -In some scenarios, it can be helpful to change how the build script works through environment variables. This is particularly useful within CI/CD workflows. - -The following environment variables can be used to override `wpPlugin` properties. - -| Environment Variable | `wpPlugin` Property | -|--------------------------|---------------------| -| `WP_PLUGIN_NAME` | `name` | - -### Example - -Here is an example job for a GitHub Actions workflow file that uses environment variables to change behavior: - -```yaml -build: - name: Build ${{ matrix.plugin-name }} plugin - runs-on: 'ubuntu-latest' - permissions: - contents: read - - strategy: - matrix: - plugin-name: [ 'my-plugin', 'my-plugin-premium' ] - - steps: - # Perform other steps to prepare for buildling (checkout repository, install dependencies, etc.) - - - name: Build plugin - run: npm run build - env: - WP_PLUGIN_NAME: ${{ matrix.plugin-name }} -``` - ## Contributing to this package This is an individual package that's part of the Gutenberg project. The project is organized as a monorepo. It's made up of multiple self-contained software packages, each with a specific purpose. diff --git a/packages/wp-build/lib/php-generator.mjs b/packages/wp-build/lib/php-generator.mjs index 462bd0ccd04a47..0a781cdffa9259 100644 --- a/packages/wp-build/lib/php-generator.mjs +++ b/packages/wp-build/lib/php-generator.mjs @@ -27,12 +27,8 @@ export async function getPhpReplacements( rootDir, baseUrlExpression ) { throw new Error( 'Could not read root package.json' ); } - const name = - process.env.WP_PLUGIN_NAME ?? - process.env.npm_package_config_WP_PLUGIN_NAME ?? - // @ts-expect-error specific override to package.json - rootPackageJson.wpPlugin?.name ?? - 'gutenberg'; + // @ts-expect-error specific override to package.json + const name = rootPackageJson.wpPlugin?.name || 'gutenberg'; const version = rootPackageJson.version; return { From 65e58026fb84142b51b91620d9c7e27820714fe0 Mon Sep 17 00:00:00 2001 From: Jonathan Desrosiers <359867+desrosj@users.noreply.github.com> Date: Fri, 6 Mar 2026 23:16:18 -0500 Subject: [PATCH 28/28] Re-add the correct GitHub Actions conditions. --- .github/workflows/build-plugin-zip.yml | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build-plugin-zip.yml b/.github/workflows/build-plugin-zip.yml index ddf34c1bc797c1..dc8e4074c84054 100644 --- a/.github/workflows/build-plugin-zip.yml +++ b/.github/workflows/build-plugin-zip.yml @@ -187,7 +187,8 @@ jobs: if: | always() && ( github.event_name == 'pull_request' || - github.event_name == 'workflow_dispatch' + github.event_name == 'workflow_dispatch' || + github.repository == 'WordPress/gutenberg' ) strategy: matrix: @@ -265,7 +266,9 @@ jobs: packages: write if: | always() && - needs.build.outputs.job_status == 'success' + needs.build.outputs.job_status == 'success' && + github.repository == 'WordPress/gutenberg' && + github.event_name == 'push' steps: - name: Download build artifact