Skip to content
Merged
Show file tree
Hide file tree
Changes from 11 commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
9efa56c
Initial update of the previews plugin package.json for changsets.
colinmurphy Jun 25, 2025
8b3fee2
Fix changeset syntax error.
colinmurphy Jun 25, 2025
f2754dd
Removed ignore directories as not required.
colinmurphy Jun 25, 2025
4e353d3
Added Changeset
colinmurphy Jun 25, 2025
1f61f66
Fixing main package-lock.json file to get e2e tests to run.
colinmurphy Jun 25, 2025
90d2934
Merge branch 'chore-setup-release-workflow-iteration-1' of github.com…
colinmurphy Jun 25, 2025
c427ec3
Setup of docs and starting to create release process.
colinmurphy Jun 25, 2025
1b418ab
Added GH workflow for plugin releases etc. No idea until we test it w…
colinmurphy Jun 25, 2025
9d59dd5
Fixed npm issue. Updated e2e test to use cached composer directory fo…
colinmurphy Jun 25, 2025
ebb0eeb
Added Changeset
colinmurphy Jun 25, 2025
62a8db4
Delete .changeset/warm-dolphins-brake.md
colinmurphy Jun 25, 2025
01401d2
Small typo fix.
colinmurphy Jun 25, 2025
8fa9253
Merge branch 'chore-setup-release-workflow-iteration-1' of github.com…
colinmurphy Jun 25, 2025
d6322d1
Simplifying PR as we only need pre-release tags not a full release pr…
colinmurphy Jun 25, 2025
3c90f66
Fixes and inlucde updating the changeset version of the plugin.
colinmurphy Jun 25, 2025
9706b07
Fixes.
colinmurphy Jun 25, 2025
ea2411a
Reverted deleting package-lock.json as it is needed for e2e tests.
colinmurphy Jun 25, 2025
69cdb6a
Updated package name. Thanks @theodesp . Updated logic of pre-release…
colinmurphy Jun 26, 2025
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
3 changes: 0 additions & 3 deletions .changeset/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,6 @@
"baseBranch": "main",
"updateInternalDependencies": "patch",
"ignore": [
"docs/",
Comment thread
colinmurphy marked this conversation as resolved.
"examples/",
"packages/"
],
"packages": [
"plugins/*"
Expand Down
6 changes: 6 additions & 0 deletions .changeset/slimy-pugs-rush.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@hwp-previews/wordpress-plugin": patch
---

chore: Initial release of hwp-previews beta release.

65 changes: 65 additions & 0 deletions .github/actions/release-plugin/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
name: 'Create Plugin Release'
description: 'Upload zip file to releases tab'
branding:
icon: 'upload-cloud'
color: 'blue'

inputs:
github_token:
description: 'GitHub Token'
required: true
php:
description: 'PHP version to use'
required: true
directory:
description: 'Plugin slug (directory name under plugins/)'
required: true
composer-options:
description: 'Additional composer options'
required: false
default: '--no-progress'

outputs:
zip-path:
description: 'Path to zip file'
value: ${{ steps.zip-main-release-for-github.outputs.zip-path }}

runs:
using: 'composite'
steps:
- id: prepare
name: Prepare Environment
run: sudo apt-get update && sudo apt-get install zip rsync -y
shell: bash

- name: Setup PHP with Cached Composer
uses: ./.github/actions/setup-php-composer
with:
php-version: ${{ inputs.php }}
working-directory: plugins/${{ inputs.slug }}
composer-options: ${{ inputs.composer-options }}

- id: create-asset-release-version
name: Create asset release version without quotes
run: |
ASSET_RELEASE_VERSION=$(echo ${{ env.VERSION }} | tr -d '"')
echo "ASSET_RELEASE_VERSION=$ASSET_RELEASE_VERSION" >> $GITHUB_ENV
shell: bash

- name: Create plugin artifact
working-directory: plugins/${{ inputs.slug }}
run: |
mkdir -p plugin-build
rm -f plugin-build/${{ inputs.slug }}-*.zip
composer archive -vvv --format=zip --file="plugin-build/${{ inputs.slug }}.${{ env.VERSION }}" --dir="."
shell: bash

- id: upload-main-release-to-github
name: Uploads the main release zip file to GitHub
uses: softprops/action-gh-release@v2
with:
token: ${{ inputs.github_token }}
files: plugins/${{ inputs.slug }}/plugin-build/${{ inputs.slug }}.${{ env.VERSION }}.zip
asset_name: ${{ inputs.slug }}.${{ env.VERSION }}.zip
tag_name: "${{ env.NAME }}@${{ env.ASSET_RELEASE_VERSION }}"
overwrite: true
15 changes: 11 additions & 4 deletions .github/workflows/e2e-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,11 @@ on:
branches:
- main
paths:
- "plugins/hwp-previews/**"
- 'plugins/hwp-previews/**.php'
- 'plugins/hwp-previews/**.js'
- 'plugins/hwp-previews/**.css'
- 'plugins/hwp-previews/**.json'

pull_request:
branches:
- main
Expand All @@ -29,9 +33,12 @@ jobs:
- name: Install dependencies
run: npm ci

- name: Install composer
run: composer install
working-directory: plugins/hwp-previews
- name: Setup PHP with Cached Composer
uses: ./.github/actions/setup-php-composer
with:
php-version: 8.2
working-directory: plugins/hwp-previews
composer-options: '--no-progress --optimize-autoloader --no-dev'

- name: Install playwright browsers
run: npx playwright install --with-deps
Expand Down
64 changes: 64 additions & 0 deletions .github/workflows/release-branch.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
name: Create Plugin Release Branch

on:
push:
branches:
- main
paths:
- "plugins/**"

jobs:
create-release-branch:
name: Create Plugin Release Branch
runs-on: ubuntu-22.04
steps:
- name: Checkout Repo
uses: actions/checkout@v4
with:
# This makes Actions fetch all Git history so that Changesets can generate changelogs with the correct commits
fetch-depth: 0

- name: Setup Node.js 18.x
uses: actions/setup-node@v4
with:
node-version: 18.x

- name: Setup pnpm
uses: pnpm/action-setup@v3
with:
version: 8 # min version for the toolkit

- name: Install Dependencies
run: pnpm install

- name: Get changed plugin directory
id: plugin
run: |
git fetch --prune --unshallow
plugin=$(git diff --name-only ${{ github.event.before }} ${{ github.sha }} | grep '^plugins/' | head -1 | cut -d/ -f2)
echo "slug=$plugin" >> $GITHUB_OUTPUT

- name: Validate package.json
run: |
if [ ! -f "plugins/${{ steps.plugin.outputs.slug }}/package.json" ]; then
echo "Exiting as no package.json file found so we cannot generate a changeset for this plugin - /${{ steps.plugin.outputs.slug }}"
exit 1
fi

- name: Gather package name
run: |
package_name=$(jq -r '.name // empty' "plugins/${{ steps.plugin.outputs.slug }}/package.json")
if [ -z "$package_name" ]; then
echo "No package name found in plugins/${{ steps.plugin.outputs.slug }}/package.json"
exit 1
fi
echo "PACKAGE_NAME=$package_name" >> $GITHUB_ENV

- name: Create Release Pull Request or Publish to npm
id: changesets
uses: changesets/action@v1
with:
publish: pnpm release
version: pnpm version:${{ steps.plugin.outputs.slug }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
76 changes: 76 additions & 0 deletions .github/workflows/release-plugin.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
name: Release Plugin

on:
push:
branches:
- main
paths:
- "plugins/**"

jobs:
create-github-release:
name: Create Github Release
runs-on: ubuntu-22.04
steps:
- name: Checkout Repo
uses: actions/checkout@v4
with:
# This makes Actions fetch all Git history so that Changesets can generate changelogs with the correct commits
fetch-depth: 0

- name: Setup Node.js 18.x
uses: actions/setup-node@v4
with:
node-version: 18.x

- name: Setup pnpm
uses: pnpm/action-setup@v3
with:
version: 8 # min version for the toolkit

- name: Install Dependencies
run: pnpm install

- name: Get changed plugin directory
id: plugin
run: |
git fetch --prune --unshallow
plugin=$(git diff --name-only ${{ github.event.before }} ${{ github.sha }} | grep '^plugins/' | head -1 | cut -d/ -f2)
echo "slug=$plugin" >> $GITHUB_OUTPUT

- name: Validate package.json
run: |
if [ ! -f "plugins/${{ steps.plugin.outputs.slug }}/package.json" ]; then
echo "Exiting as no package.json file found so we cannot generate a changeset for this plugin - /${{ steps.plugin.outputs.slug }}"
exit 1
fi

- name: Gather package name
run: |
package_name=$(jq -r '.name // empty' "plugins/${{ steps.plugin.outputs.slug }}/package.json")
if [ -z "$package_name" ]; then
echo "No package name found in plugins/${{ steps.plugin.outputs.slug }}/package.json"
exit 1
fi
echo "PACKAGE_NAME=$package_name" >> $GITHUB_ENV

- name: Save Plugin version
run: |
json=${{ toJSON(steps.changesets.outputs.publishedPackages) }}
echo PLUGIN_VERSION=$(echo "$json" | jq --arg name "$PACKAGE_NAME" '.[] | select(.name == $name) | .version') >> $GITHUB_ENV

- name: Create Github Release
# Checks the changesets publishedPackages output
# If there is a published package named after the plugin slug,
# Then deploy the WordPress plugin
# https://github.com/changesets/action#outputs
if: steps.changesets.outputs.published && contains(steps.changesets.outputs.publishedPackages, format('"{0}"', steps.plugin.outputs.slug))
uses: ./.github/actions/release-plugin
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
php: 8.2
composer-options: '--no-progress --optimize-autoloader --no-dev'
slug: ${{ steps.plugin.outputs.slug }}
env:
VERSION: ${{ env.PLUGIN_VERSION }}
NAME: ${{ env.PACKAGE_NAME }}
3 changes: 3 additions & 0 deletions HOW_WE_WORK.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ We believe in transparent, collaborative development. These guidelines document
- Schedule releases Monday-Wednesday only
- Distribute to WPE Updater and WordPress.org when applicable

>[!NOTE]
> Our plugin release process is explained under [docs/explanation/hwp-toolkit-plugin-release-process.md](docs/explanation/hwp-toolkit-plugin-release-process.md)

## Effective Communication

- Work in public by default (except for security/private infrastructure)
Expand Down
59 changes: 59 additions & 0 deletions docs/explanation/hwp-toolkit-plugin-release-process.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
# Overview

This is an explanation on how a plugin is released on GitHub.

# Workflow

## High Level project structure for release process

```
.
└── package.json # Contains scripts to update the different plugin versions
└── .changeset
│ └── config.json # Changeset config file
├── .github
│ └── workflows
│ ├── release-branch.yml # Creates the release branch
│ └── release-plugin.yml # Creates the GitHub release
├── plugin
│ └── hwp-previews
│ └── package.json # Required for changeset to work
│ └── wp-graphql-headless-webhooks
│ └── package.json # Required for changeset to work
├── scripts/
│ └── plugin-version
│ ├── previewsVersionPlugin.js # Updates the version of hwp-previews plugin
│ └── webhooksVersionPlugin.js # Updates the version of wp-graphql-headless-webhooks plugin
```

## 1. PR creation

1. A create PR is created for a plugin
2. This triggers the [changeset bot](https://github.com/changesets/bot) to check for a changeset.
3. A user can add a changeset manually by running `npm run changeset` or if they are a maintainer, they can do this also in GitHub
4. Once the PR is merged the following actions will take place:


## 2. PR merged to the main branch

This will trigger the release workflow [release-branch.yml](../../.github/workflows/release-branch.yml) and the workflow will do the following:

1. Check to see if a changeset exists
2. Check that a plugin is modified
3. Create a release branch for that plugin using `npm run build && changeset publish
4. Depending on what plugin is changed it will either run `npm run version:previews` or `npm run version:webhooks` which will call a script for updating the plugin version under [scripts/plugin-version](../../scripts/plugin-version/)

After this a plugin release branch is created. See <https://github.com/wpengine/hwptoolkit/pulls?q=Plugin+Release>

>[!NOTE]
> If you are adding a new plugin, you will need to add a script and also update this workflow, along with adding a package.json while updating the main package-lock.json by running `npm install`


## 3. Plugin Release Branch

The plugin release branch should contain some updates to the plugin and mainly the plugin version number.

Once approved and merged this will trigger the [release-plugin.yml](../../.github/workflows/release-plugin.yml)

This will then create a release for the plugin under [Github releases](https://github.com/wpengine/hwptoolkit/releases)
Loading
Loading