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
34 changes: 10 additions & 24 deletions .github/workflows/pull-request-version.yml
Original file line number Diff line number Diff line change
@@ -1,38 +1,24 @@
name: "Check plugin version and tags"
name: "Check plugin version and release files"
on:
pull_request:
branches:
- main

jobs:
version-check:
name: "Check version doesn't not already exists."
name: "Version bump, tag, and file checks"
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
fetch-depth: 0

- id: set-vars
name: "Set variables from .plugin-data file"
run: |
# Get all data from .plugin-data file
content=`cat ./.plugin-data`
# the following lines are only required for multi line json
content="${content//'%'/'%25'}"
content="${content//$'\n'/'%0A'}"
content="${content//$'\r'/'%0D'}"
# end of optional handling for multi line json
echo "::set-output name=pluginData::$content"
- name: Fetch tags
run: git fetch --tags --prune origin

- id: version-check
name: "Check version in .plugin-data is not existing"
run: |
# Check version from .plugin-data
VERSION=${{fromJson(steps.set-vars.outputs.pluginData).version}}

if git rev-parse "$VERSION" >/dev/null 2>&1; then
echo "Tag aleady exists please update the .plugin-data file to good version";
exit 1;
fi
- name: Verify version bump and release files
env:
BASE_SHA: ${{ github.event.pull_request.base.sha }}
HEAD_SHA: ${{ github.event.pull_request.head.sha }}
run: tests/bin/check-release-version.sh
11 changes: 9 additions & 2 deletions .github/workflows/quality-js.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,15 @@ name: Javascript Quality Checks

on:
pull_request:
paths:
- 'src/**'
paths:
- 'src/**'
- 'package.json'
push:
paths:
- 'src/**'
- 'package.json'
branches:
- main

# Cancels all previous workflow runs for pull requests that have not completed.
concurrency:
Expand Down
14 changes: 8 additions & 6 deletions .github/workflows/quality-php.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
name: Quality PHP
name: PHP Quality Checks

on:
pull_request:
paths:
- '**.php'
push:
branches:
- main

# Cancels all previous workflow runs for pull requests that have not completed.
concurrency:
Expand All @@ -13,9 +14,10 @@ concurrency:
cancel-in-progress: true

jobs:
build:
checks:
name: Lint PHP
runs-on: ubuntu-latest
name: PHP quality

steps:
- name: Checkout project
uses: actions/checkout@v3
Expand All @@ -24,7 +26,7 @@ jobs:
uses: shivammathur/setup-php@v2
with:
php-version: 8.1
extensions: mbstring, intl #optional, setup extensions
extensions: mbstring, intl

- name: Setup Composer
run: |
Expand Down
23 changes: 15 additions & 8 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,21 +38,28 @@ jobs:
exit 1;
fi

- id: build-node
name: "Build project CSS and JS"
uses: actions/setup-node@v4
with:
node-version-file: 'package.json'
- run: npm install
- run: npm run build

- id: build-php
name: "Build project PHP"
uses: shivammathur/setup-php@v2
with:
php-version: 8.1
- run: composer install --prefer-dist --no-dev -o --ignore-platform-reqs

- id: setup-node
name: "Setup Node.js"
uses: actions/setup-node@v4
with:
node-version-file: 'package.json'
cache: 'npm'

- id: build-js
name: "Build JavaScript assets"
run: |
echo "Install npm dependencies"
npm ci
echo "Build assets"
npm run build

- id: commit-and-push
name: "Commit and push new TAG"
run: |
Expand Down
2 changes: 1 addition & 1 deletion .plugin-data
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"version": "1.1.0",
"version": "1.1.1",
"slug": "blockparty-icons"
}
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@ This plugin **doesn't run any sanitization on SVGs** before using them. Only use

## Changelog

### 1.1.1 - 2026-08-26

- Fix deprecated warning for nullable string parameters in `CollectionItem`
- Align GitHub workflows with other blockparty repos and add release version consistency checks

### 1.1.0 - 2026-08-14

- Add WP-CLI command to convert `beapi/icon-block` / `beapi/icon-item` old contents to `blockparty/icon`
Expand Down
4 changes: 2 additions & 2 deletions blockparty-icons.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* Description: Provides blocks in WordPress editor to add custom SVG icons.
* Requires at least: 6.2
* Requires PHP: 8.1
* Version: 1.1.0
* Version: 1.1.1
* Author: Be API Technical Team
* Author URI: https://beapi.fr
* License: GPL-2.0-or-later
Expand All @@ -30,7 +30,7 @@
include_once __DIR__ . '/vendor/autoload.php';
}

define( 'BLOCKPARTY_ICONS_VERSION', '1.1.0' );
define( 'BLOCKPARTY_ICONS_VERSION', '1.1.1' );
define( 'BLOCKPARTY_ICONS_URL', plugin_dir_url( __FILE__ ) );
define( 'BLOCKPARTY_ICONS_DIR', plugin_dir_path( __FILE__ ) );
define( 'BLOCKPARTY_ICONS_PLUGIN_BASENAME', plugin_basename( __FILE__ ) );
Expand Down
12 changes: 6 additions & 6 deletions includes/Icon/CollectionItem.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@

class CollectionItem {

private $name;
private $label;
private $type;
private $version;
private $content;
private string $name;
private ?string $label;
private string $type;
private ?string $version;
private string $content;

public function __construct( string $name, string $type, string $content, string $label = null, string $version = null ) {
public function __construct( string $name, string $type, string $content, ?string $label = null, ?string $version = null ) {
$this->name = $name;
$this->type = $type;
$this->content = $content;
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "blockparty-icons",
"version": "1.1.0",
"version": "1.1.1",
"description": "Provides blocks in WordPress editor to add custom SVG icons from your theme.",
"author": "Be API Technical team",
"license": "GPL-2.0-or-later",
Expand Down
6 changes: 5 additions & 1 deletion readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Tags: block, icons, svg, gutenberg, editor
Requires at least: 6.2
Tested up to: 6.8
Requires PHP: 8.1
Stable tag: 1.1.0
Stable tag: 1.1.1
License: GPL-2.0-or-later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Expand Down Expand Up @@ -36,6 +36,10 @@ Yes. Register a collection with `type` set to `folder` and `source` pointing to

== Changelog ==

= 1.1.1 =
* Fix deprecated warning for nullable string parameters in `CollectionItem`.
* Align GitHub workflows with other blockparty repos and add release version consistency checks.

= 1.1.0 =
* Add WP-CLI command to convert `beapi/icon-block` / `beapi/icon-item` old content to `blockparty/icon`.

Expand Down
2 changes: 1 addition & 1 deletion src/block.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"$schema": "https://schemas.wp.org/trunk/block.json",
"apiVersion": 3,
"name": "blockparty/icon",
"version": "1.1.0",
"version": "1.1.1",
"title": "Icon",
"category": "widgets",
"description": "Easily add custom vector icon to your content.",
Expand Down
139 changes: 139 additions & 0 deletions tests/bin/check-release-version.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@
#!/usr/bin/env bash
#
# When .plugin-data version changes between base and head commits, verify
# the release tag is unused and that every versioned file is updated consistently.
#
# Usage (from repository root):
# ./tests/bin/check-release-version.sh
# (default: merge-base of main|origin/main|master with HEAD → HEAD, for local runs)
# BASE_SHA=<base> HEAD_SHA=<head> ./tests/bin/check-release-version.sh
# ./tests/bin/check-release-version.sh <base_sha> <head_sha>
#
# GitHub Actions sets BASE_SHA and HEAD_SHA on the pull request; arguments override env.
#

set -euo pipefail

SCRIPT_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
ROOT=$(cd "$SCRIPT_DIR/../.." && pwd)
cd "$ROOT"

if [ $# -ge 2 ]; then
BASE_SHA=$1
HEAD_SHA=$2
fi

if [ -z "${BASE_SHA:-}" ] || [ -z "${HEAD_SHA:-}" ]; then
if [ $# -eq 0 ] && git -C "$ROOT" rev-parse --is-inside-work-tree >/dev/null 2>&1; then
HEAD_SHA=$(git -C "$ROOT" rev-parse HEAD)
base_ref=
for r in main origin/main master origin/master; do
if git -C "$ROOT" rev-parse -q --verify "$r" >/dev/null 2>&1; then
base_ref=$r
break
fi
done
if [ -n "$base_ref" ] && MB=$(git -C "$ROOT" merge-base "$base_ref" HEAD 2>/dev/null); then
BASE_SHA=$MB
echo "Using ${base_ref}..HEAD: merge-base ${BASE_SHA:0:7} → head ${HEAD_SHA:0:7}" >&2
fi
fi
fi

if [ -z "${BASE_SHA:-}" ] || [ -z "${HEAD_SHA:-}" ]; then
echo "Usage: BASE_SHA=<commit> HEAD_SHA=<commit> $0" >&2
echo " or: $0 <base_sha> <head_sha>" >&2
echo " or: $0 (in a git repo, compares merge-base of main|origin/main|... with HEAD)" >&2
exit 1
fi

NEW_VER=$(jq -r .version .plugin-data)

if ! git cat-file -e "${BASE_SHA}:.plugin-data" 2>/dev/null; then
echo "::error::Could not read .plugin-data at merge base. Ensure the base branch has .plugin-data."
exit 1
fi

OLD_VER=$(git show "${BASE_SHA}:.plugin-data" | jq -r .version)

if [ "$OLD_VER" = "$NEW_VER" ]; then
echo "No version change in .plugin-data (${NEW_VER}). Skipping release and tag checks."
exit 0
fi

echo "Version bump detected: ${OLD_VER} -> ${NEW_VER}"

if git show-ref --verify --quiet "refs/tags/${NEW_VER}"; then
echo "::error::Tag '${NEW_VER}' already exists. Bump .plugin-data to a version that is not released yet."
exit 1
fi

have_diff() {
[ -n "$(git diff --name-only "${BASE_SHA}" "${HEAD_SHA}" -- "$1")" ]
}

missing=()
for f in \
.plugin-data \
package.json \
blockparty-icons.php \
readme.txt \
CHANGELOG.md
do
if ! have_diff "$f"; then
missing+=("$f")
fi
done

while IFS= read -r -d '' f; do
if ! have_diff "$f"; then
missing+=("$f (block.json)")
fi
done < <(find . -name block.json -not -path '*/node_modules/*' -not -path '*/vendor/*' -print0 2>/dev/null)

if [ ${#missing[@]} -ne 0 ]; then
echo "::error::This PR bumps the plugin version. The following required paths must be modified (diff vs base branch):"
printf ' - %s\n' "${missing[@]}"
exit 1
fi

# Consistency: declared version must match .plugin-data everywhere
fail=0
if [ "$(jq -r .version package.json)" != "$NEW_VER" ]; then
echo "::error::package.json version must equal ${NEW_VER} (from .plugin-data)"
fail=1
fi

while IFS= read -r -d '' f; do
if [ "$(jq -r .version "$f")" != "$NEW_VER" ]; then
echo "::error::${f} version must equal ${NEW_VER} (from .plugin-data)"
fail=1
fi
done < <(find . -name block.json -not -path '*/node_modules/*' -not -path '*/vendor/*' -print0 2>/dev/null)

if ! grep -F "* Version:" blockparty-icons.php | head -1 | grep -qF "$NEW_VER"; then
echo "::error::blockparty-icons.php plugin header Version must be ${NEW_VER}"
fail=1
fi

if ! grep -qF "define( 'BLOCKPARTY_ICONS_VERSION', '$NEW_VER' );" blockparty-icons.php; then
echo "::error::blockparty-icons.php define BLOCKPARTY_ICONS_VERSION must be '${NEW_VER}'"
fail=1
fi

if ! grep -E "^Stable tag:" readme.txt | grep -qF "$NEW_VER"; then
echo "::error::readme.txt Stable tag must be ${NEW_VER}"
fail=1
fi

if ! grep -qF "= ${NEW_VER} =" readme.txt; then
echo "::error::readme.txt Changelog must include '= ${NEW_VER} =' section"
fail=1
fi

if ! grep -qF "$NEW_VER" CHANGELOG.md; then
echo "::error::CHANGELOG.md must mention the release version ${NEW_VER} (e.g. a [${NEW_VER}] section header)"
fail=1
fi

exit "$fail"
Loading