Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
cdb72ae
Publish the built plugin zip.
desrosj Feb 24, 2026
d7def76
`always()` check is necessary.
desrosj Mar 6, 2026
3f8706d
Do not attempt to publish to GHCR in forks.
desrosj Feb 24, 2026
1679a20
Hardcode the org/repository.
desrosj Feb 24, 2026
7a2316e
Prepare a plugin artifact for `wordpress-develop`
desrosj Feb 25, 2026
7904fda
# This is a combination of 6 commits.
desrosj Feb 25, 2026
a3622f0
Publish the built plugin zip.
desrosj Mar 6, 2026
27e5999
# This is a combination of 5 commits.
desrosj Feb 25, 2026
afb6210
Make the package name more specific.
desrosj Mar 6, 2026
fbb61e3
Allow plugin name to be overridden.
desrosj Feb 26, 2026
521eb9c
Allow plugin name to be overridden.
desrosj Mar 6, 2026
1b2ce86
# This is a combination of 4 commits.
desrosj Mar 6, 2026
3217d23
Allow plugin name to be overridden.
desrosj Mar 6, 2026
9aae931
Make the default `base-url` value context aware.
desrosj Mar 6, 2026
c2ac060
Allow relevant values to be overridden more easily
desrosj Mar 6, 2026
e0e9485
Skip PHP transforms when building for WP Core.
desrosj Feb 27, 2026
a811c3d
Document environment variable in README.
desrosj Feb 28, 2026
5186219
Improve utility function name and inline docs.
desrosj Mar 6, 2026
9f6a64c
Update CHANGELOG.
desrosj Mar 6, 2026
ee04ae6
Account for more truthy values in `castBool`
desrosj Mar 6, 2026
fcdd69b
Remove unrelated change.
desrosj Mar 2, 2026
d9ced68
Add a description to the ORAS step.
desrosj Mar 2, 2026
8aa52bc
Switch to using `.gz` over `.zip`.
desrosj Mar 2, 2026
387f52d
Improvements to the boolean casting function.
desrosj Mar 6, 2026
1bbed3c
Final coding standards fixes.
desrosj Mar 6, 2026
c201f84
Remove stray unnecessary `eslint-enable`.
desrosj Mar 6, 2026
9a1f7d8
Remove the `WP_PLUGIN_NAME` env variable.
desrosj Mar 7, 2026
65e5802
Re-add the correct GitHub Actions conditions.
desrosj Mar 7, 2026
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
72 changes: 70 additions & 2 deletions .github/workflows/build-plugin-zip.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -190,6 +190,15 @@ jobs:
github.event_name == 'workflow_dispatch' ||
github.repository == 'WordPress/gutenberg'
)
strategy:
matrix:
IS_GUTENBERG_PLUGIN: [true]
IS_WORDPRESS_CORE: [false]

include:
- IS_GUTENBERG_PLUGIN: false
IS_WORDPRESS_CORE: true

outputs:
job_status: ${{ job.status }}

Expand All @@ -207,15 +216,21 @@ 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 }}

- name: Upload artifact
uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0
with:
name: gutenberg-plugin
name: gutenberg-${{ matrix.IS_WORDPRESS_CORE && 'wordpress-develop' || 'plugin' }}
path: ./gutenberg.zip

- name: Build release notes draft
Expand All @@ -241,6 +256,59 @@ 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: |
always() &&
needs.build.outputs.job_status == 'success' &&
github.repository == 'WordPress/gutenberg' &&
github.event_name == 'push'

steps:
- name: Download build artifact
uses: actions/download-artifact@37930b1c2abaa49bbe596cd826c3c89aef350131 # v7.0.0
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: 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
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

# 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
Comment thread
desrosj marked this conversation as resolved.

# 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
run: |
oras push "ghcr.io/wordpress/gutenberg/gutenberg-wp-develop-build:${{ github.sha }}" \
"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 }}"

revert-version-bump:
name: Revert version bump if build failed
needs: [bump-version, build]
Expand Down
6 changes: 6 additions & 0 deletions packages/wp-build/.eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -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',
},
};
5 changes: 5 additions & 0 deletions packages/wp-build/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@

## Unreleased

### Enhancements

- 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)
Expand Down
33 changes: 30 additions & 3 deletions packages/wp-build/lib/build.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -113,12 +113,27 @@ const HANDLE_PREFIX = WP_PLUGIN_CONFIG.handlePrefix || PACKAGE_NAMESPACE;
const EXTERNAL_NAMESPACES = WP_PLUGIN_CONFIG.externalNamespaces || {};
const PAGES = WP_PLUGIN_CONFIG.pages || [];

/**
* Interprets a configuration value as a boolean, where `"true"` and `"1"`
* are considered true while all other values are false.
*
* @param {string|undefined} value The configuration value to interpret.
* @return {boolean} Boolean interpretation of the given configuration value.
*/
const boolConfigVal = ( value ) => {
return (
value !== undefined && [ 'true', '1' ].includes( value.toLowerCase() )
);
};

const baseDefine = {
'globalThis.IS_GUTENBERG_PLUGIN': JSON.stringify(
Boolean( 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( 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 ) => ( {
Expand Down Expand Up @@ -315,6 +330,16 @@ function transformPhpContent( content, transforms ) {

content = content.toString();

/*
* 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 ( boolConfigVal( process.env.IS_WORDPRESS_CORE ) ) {
return content;
}

if ( prefixFunctions.length ) {
content = content.replace(
new RegExp( prefixFunctions.join( '|' ), 'g' ),
Expand Down Expand Up @@ -2142,7 +2167,9 @@ async function main() {
},
'base-url': {
type: 'string',
default: 'plugin_dir_url( __FILE__ )',
default: boolConfigVal( process.env.IS_WORDPRESS_CORE )
? "includes_url( 'build/' )"
: 'plugin_dir_url( __FILE__ )',
},
},
strict: false,
Expand Down
Loading