Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
20 changes: 20 additions & 0 deletions .github/workflows/build-release-branch.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: Build to "release" branch

on:
push:
branches:
- main

concurrency:
group: ${{ github.workflow }}-${{ github.ref_name }}
cancel-in-progress: true

jobs:
release:
name: "Update release branch"
uses: humanmade/hm-github-actions/.github/workflows/build-and-release-node.yml@0813c0d62e0657037f42da83bc6804b0fc8ec9af # v0.4.0
with:
node_version: 22
source_branch: main
release_branch: release
built_asset_paths: build
46 changes: 46 additions & 0 deletions .github/workflows/php.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: PHP Code Quality

on:
pull_request:
types:
- opened
- reopened
- synchronize
- ready_for_review
# Only run when PHP or the coding standards configuration change.
paths:
- '**.php'
- '.phpcs.xml'
- 'composer.json'
- 'composer.lock'

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
phpcs:
name: PHPCS
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0

- name: Set up PHP
uses: shivammathur/setup-php@f3e473d116dcccaddc5834248c87452386958240 # 2.37.2
with:
php-version: '8.2'
coverage: none
tools: cs2pr

- name: Install Composer dependencies
run: composer install --no-progress --no-interaction --no-ansi

- name: Run PHPCS
id: phpcs
run: composer phpcs -- --report-full --report-checkstyle=phpcs-report.xml

- name: Annotate PR with PHPCS results
if: ${{ always() && steps.phpcs.outcome == 'failure' }}
run: cs2pr ./phpcs-report.xml
47 changes: 47 additions & 0 deletions .github/workflows/tag-and-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: Tag and Release

on:
workflow_dispatch:
inputs:
version:
description: 'Version tag (e.g., v1.0.0)'
required: true

jobs:
tag_and_release:
name: Tag and Release
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0

- name: Check if tag already exists
id: check_tag
run: |
if git rev-parse "refs/tags/${{ github.event.inputs.version }}" >/dev/null 2>&1; then
echo "Tag already exists"
echo "tag_exists=true" >> "$GITHUB_OUTPUT"
fi

- name: Abort if tag exists
if: steps.check_tag.outputs.tag_exists == 'true'
run: exit 1

- name: Create and push tag
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git fetch origin release
git checkout release
git tag ${{ github.event.inputs.version }}
git push origin ${{ github.event.inputs.version }}

- name: Create GitHub Release
uses: ncipollo/release-action@339a81892b84b4eeb0f6e744e4574d79d0d9b8dd # v1.21.0
with:
tag: ${{ github.event.inputs.version }}
name: ${{ github.event.inputs.version }}
body: "Automated release of version ${{ github.event.inputs.version }}"
draft: false
prerelease: false
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
node_modules

/build/
/vendor/
37 changes: 37 additions & 0 deletions .phpcs.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<?xml version="1.0"?>
<ruleset name="Query Filter Coding Standards">
<description>Human Made Coding Standards</description>

<!-- What to scan -->
<file>./inc/</file>
<file>./src/</file>
<file>query-filter.php</file>

<exclude-pattern>./build/</exclude-pattern>
<exclude-pattern>./vendor/</exclude-pattern>

<!-- How to scan -->
<arg value="sp"/> <!-- Show sniff and progress -->
<arg name="colors"/> <!-- Show results with colors (disable if working on Windows). -->
<arg name="basepath" value="."/> <!-- Show paths as the relevant relative path. -->
<arg name="parallel" value="8"/> <!-- Enables parallel processing when available. -->

<!-- Support recent versions of WordPress. -->
<config name="minimum_supported_wp_version" value="6.8"/>

<!-- Human Made Coding Standards -->
<rule ref="HM">
<!-- These stylistic-only rules are disabled temporarily and should be fixed in follow-up. -->
<exclude name="PSR12.Functions.ReturnTypeDeclaration.SpaceBeforeColon" />
<exclude name="WordPress.Arrays.ArrayDeclarationSpacing" />
<exclude name="Squiz.Commenting" />
<exclude name="Squiz.Strings.ConcatenationSpacing" />
<exclude name="Generic.Commenting" />
<exclude name="Squiz.Commenting.FileComment.Missing" />
<exclude name="NormalizedArrays.Arrays.ArrayBraceSpacing" />
</rule>

<rule ref="HM.Files.NamespaceDirectoryName.NoIncDirectory">
<exclude-pattern>query-filter.php</exclude-pattern>
</rule>
</ruleset>
22 changes: 22 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,25 @@ This plugin is available on packagist.
1. Download the plugin from the [GitHub repository](https://github.com/humanmade/query-filter).
2. Upload the plugin to your site's `wp-content/plugins` directory.
3. Activate the plugin from the WordPress admin.

Built assets are not committed to `main`. Manual or Composer installs should track the `release` branch (or a tagged release), which contains the compiled `build` directory.

## Release Process

Merges to `main` automatically [build](https://github.com/humanmade/query-filter/actions/workflows/build-release-branch.yml) to the `release` branch. A project may track the `release` branch using [Composer](https://getcomposer.org/) to pull in the latest built beta version.

Commits on the `release` branch may be tagged for installation via [Packagist](https://packagist.org/packages/humanmade/query-filter) and marked as releases in GitHub for manual download, using a manually-dispatched ["Tag and Release" GH Actions workflow](https://github.com/humanmade/query-filter/actions/workflows/tag-and-release.yml).

To tag a new release:

1. Choose the target version number using [semantic versioning](https://semver.org/).
2. Check out a `prepare-v#.#.#` branch and bump the `Version` in the [query-filter.php](./query-filter.php) PHPDoc header.
3. Open a pull request titled "Prepare release v#.#.#".
4. Review and merge the "Prepare release" pull request.
5. Wait for the `release` branch to [update](https://github.com/humanmade/query-filter/actions/workflows/build-release-branch.yml) with the build that includes the new version number.
6. On the ["Tag and Release" GH Action page](https://github.com/humanmade/query-filter/actions/workflows/tag-and-release.yml):
- Click "Run workflow" in the `workflow_dispatch` banner.
- Fill out the "Version tag" field with your target version number. This must match the `Version` in `query-filter.php`. Use the format `v#.#.#`.
- Click "Run workflow" to apply the specified tag to the `release` branch.

Once the workflow completes, the new version is [tagged](https://github.com/humanmade/query-filter/tags) and listed in [releases](https://github.com/humanmade/query-filter/releases).
66 changes: 0 additions & 66 deletions build/post-type/block.json

This file was deleted.

1 change: 0 additions & 1 deletion build/post-type/index.asset.php

This file was deleted.

1 change: 0 additions & 1 deletion build/post-type/index.js

This file was deleted.

1 change: 0 additions & 1 deletion build/post-type/index.js.map

This file was deleted.

Loading
Loading