diff --git a/.github/workflows/pull-request-version.yml b/.github/workflows/pull-request-version.yml index 2d2df4e..7ae8b57 100644 --- a/.github/workflows/pull-request-version.yml +++ b/.github/workflows/pull-request-version.yml @@ -1,4 +1,4 @@ -name: "Check plugin version and tags" +name: "Check plugin version and release files" on: pull_request: branches: @@ -6,33 +6,19 @@ on: 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 diff --git a/.github/workflows/quality-js.yml b/.github/workflows/quality-js.yml index 798f4f2..16fdf38 100644 --- a/.github/workflows/quality-js.yml +++ b/.github/workflows/quality-js.yml @@ -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: diff --git a/.github/workflows/quality-php.yml b/.github/workflows/quality-php.yml index ed79cdc..2100ba7 100644 --- a/.github/workflows/quality-php.yml +++ b/.github/workflows/quality-php.yml @@ -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: @@ -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 @@ -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: | diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index f058c20..489ffd9 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -38,14 +38,6 @@ 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 @@ -53,6 +45,21 @@ jobs: 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: | diff --git a/.plugin-data b/.plugin-data index 9425050..91edf44 100644 --- a/.plugin-data +++ b/.plugin-data @@ -1,4 +1,4 @@ { - "version": "1.1.0", + "version": "1.1.1", "slug": "blockparty-icons" } diff --git a/CHANGELOG.md b/CHANGELOG.md index 106e882..4756984 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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` diff --git a/blockparty-icons.php b/blockparty-icons.php index 5ac3209..c294308 100644 --- a/blockparty-icons.php +++ b/blockparty-icons.php @@ -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 @@ -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__ ) ); diff --git a/includes/Icon/CollectionItem.php b/includes/Icon/CollectionItem.php index 0914ece..f2c716f 100644 --- a/includes/Icon/CollectionItem.php +++ b/includes/Icon/CollectionItem.php @@ -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; diff --git a/package-lock.json b/package-lock.json index 0ca9864..aa22b2a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "blockparty-icons", - "version": "1.0.8", + "version": "1.1.1", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "blockparty-icons", - "version": "1.0.8", + "version": "1.1.1", "license": "GPL-2.0-or-later", "dependencies": { "@beapi/icons": "^1.2.5", diff --git a/package.json b/package.json index 60d0c3f..0c18322 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/readme.txt b/readme.txt index 12b6c02..3c5ef0a 100644 --- a/readme.txt +++ b/readme.txt @@ -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 @@ -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`. diff --git a/src/block.json b/src/block.json index 37a95d2..ffd022b 100644 --- a/src/block.json +++ b/src/block.json @@ -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.", diff --git a/tests/bin/check-release-version.sh b/tests/bin/check-release-version.sh new file mode 100755 index 0000000..7585107 --- /dev/null +++ b/tests/bin/check-release-version.sh @@ -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= HEAD_SHA= ./tests/bin/check-release-version.sh +# ./tests/bin/check-release-version.sh +# +# 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= HEAD_SHA= $0" >&2 + echo " or: $0 " >&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"