Skip to content
Open
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
8 changes: 1 addition & 7 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -1,7 +1 @@
src/resources/postcss/utilities/
vendor/
build/
node_modules/
tests/
common/
**/__tests__/**
src/resources/js/**/*.min.js
40 changes: 40 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: 'npm lint'
on:
pull_request:
workflow_dispatch:
paths:
- 'src/modules/**.js'
- 'src/resources/js/**.js'
- 'src/resources/postcss/**.pcss'
jobs:
lint:
runs-on: ubuntu-latest
if: "!contains(github.event.pull_request.body, '[skip-lint]')"
steps:
- name: Checkout the repository
uses: actions/checkout@v4
with:
fetch-depth: 1
submodules: recursive
# ------------------------------------------------------------------------------
# Setup Node.
# ------------------------------------------------------------------------------
- name: Check for .nvmrc file
id: check-nvmrc
run: |
if [ -f "${{ github.workspace }}/.nvmrc" ]; then
echo "exists=true" >> $GITHUB_OUTPUT
else
echo "exists=false" >> $GITHUB_OUTPUT
fi

- uses: actions/setup-node@v4
if: steps.check-nvmrc.outputs.exists == 'true'
with:
node-version-file: '.nvmrc'
cache: 'npm'
cache-dependency-path: package-lock.json
- name: Install node modules
run: npm ci
- name: Run linting tasks
run: npm run lint
35 changes: 21 additions & 14 deletions .github/workflows/phpcs.yml
Original file line number Diff line number Diff line change
@@ -1,17 +1,11 @@
name: 'PHPCS'
on:
pull_request:
types:
- opened
- synchronize
- reopened
- edited
on: [pull_request]
jobs:
conditional:
if: "!contains(github.event.pull_request.body, '[skip-phpcs]')"
runs-on: ubuntu-latest
outputs:
run_tests: ${{ steps.php_check.outputs.php_files_changed }}
has_no_php_changes: ${{ steps.skip.outputs.has_no_php_changes }}
steps:
# ------------------------------------------------------------------------------
# Checkout the repo
Expand All @@ -25,15 +19,28 @@ jobs:
# ------------------------------------------------------------------------------
# Check if any PHP files have changed
# ------------------------------------------------------------------------------
- name: Check for PHP file changes
id: php_check
uses: ./.github/actions/check-php-changes
- name: Check PHP file changes
id: skip
run: |
php_files=$(git diff ${{ github.event.pull_request.base.sha }} HEAD --name-only | grep -E '\.php$' || true)
num_php_files=$(echo "$php_files" | grep -c '^' || echo 0)

if [[ -z "$php_files" || "$num_php_files" -eq 0 ]]; then
echo "has_no_php_changes=1" >> $GITHUB_OUTPUT
echo "## No PHP files changed" >> $GITHUB_STEP_SUMMARY
echo "PHPCS will not run." >> $GITHUB_STEP_SUMMARY
else
echo "has_no_php_changes=0" >> $GITHUB_OUTPUT
echo "## Found PHP file changes" >> $GITHUB_STEP_SUMMARY
echo "Total changed PHP files: $num_php_files" >> $GITHUB_STEP_SUMMARY
echo "$php_files" | sed 's/^/- /' >> $GITHUB_STEP_SUMMARY
fi
phpcs:
needs: conditional
if: needs.conditional.outputs.run_tests
needs:
- conditional
if: needs.conditional.outputs.has_no_php_changes == '0'
uses: stellarwp/github-actions/.github/workflows/phpcs.yml@main
with:
ref: ${{ github.event.inputs.ref }}
change_permissions: false
secrets:
access-token: ${{ secrets.GH_BOT_TOKEN }}
2 changes: 2 additions & 0 deletions .github/workflows/release-merge-forward.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ jobs:
with:
ref: ${{ github.event.inputs.forward-branch }}
fetch-depth: 0
submodules: recursive

- name: Set up Git configuration
run: |
Expand Down Expand Up @@ -56,6 +57,7 @@ jobs:
uses: actions/checkout@v4
with:
fetch-depth: 0
submodules: recursive

- name: Set up Git configuration
run: |
Expand Down
128 changes: 128 additions & 0 deletions .github/workflows/release-update-wp-version.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
name: "Release: Update WordPress Version"

on:
workflow_dispatch:
inputs:
tested_up_to:
description: 'WordPress version to set as "tested up to" version (e.g. 6.8.1)'
required: true
type: string
update_min_version:
description: 'Update minimum required version to 2 minor versions behind tested version? (e.g. 6.8.1 -> 6.6)'
required: true
type: choice
options:
- 'yes'
- 'no'
default: 'no'

jobs:
update-versions:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
ref: ${{ github.ref }}

- name: Set Variables
id: vars
run: |
echo "sha_short=$(git rev-parse --short ${{ github.sha }})" >> $GITHUB_OUTPUT
echo "timestamp=$(date +%Y%m%d-%H%M%S)" >> $GITHUB_OUTPUT

- name: Set up Git configuration
run: |
git config --global user.email "actions@github.com"
git config --global user.name "github-actions"

- name: Create branch for changes
id: create-branch
run: |
BRANCH_NAME="task/update-wp-version-${{ steps.vars.outputs.timestamp }}-${{ steps.vars.outputs.sha_short }}"
git checkout -b "$BRANCH_NAME"
git push --set-upstream origin "$BRANCH_NAME"
echo "branch_name=$BRANCH_NAME" >> $GITHUB_OUTPUT

- name: Calculate and update versions
id: update-versions
run: |
TESTED_VERSION="${{ github.event.inputs.tested_up_to }}"
IFS='.' read -r -a tested_parts <<< "$TESTED_VERSION"

# Calculate minimum version (2 minor versions behind, using only major.minor)
min_major=$((tested_parts[0]))
min_minor=$((tested_parts[1] - 2))
MIN_VERSION="$min_major.$min_minor"

echo "## Version Updates" >> $GITHUB_STEP_SUMMARY
echo "* Tested Up To: \`$TESTED_VERSION\`" >> $GITHUB_STEP_SUMMARY

if [ "${{ github.event.inputs.update_min_version }}" = "yes" ]; then
echo "* Minimum Required Version: \`$MIN_VERSION\`" >> $GITHUB_STEP_SUMMARY
else
echo "* Minimum Required Version: Unchanged" >> $GITHUB_STEP_SUMMARY
fi

# Update readme.txt
if [ -f "readme.txt" ]; then
sed -i "s/Tested up to: [0-9.]*/Tested up to: $TESTED_VERSION/" readme.txt
if [ "${{ github.event.inputs.update_min_version }}" = "yes" ]; then
sed -i "s/Requires at least: [0-9.]*/Requires at least: $MIN_VERSION/" readme.txt
fi
echo "* Updated \`readme.txt\`" >> $GITHUB_STEP_SUMMARY
fi

# Update plugin.php if minimum version is being updated
if [ "${{ github.event.inputs.update_min_version }}" = "yes" ]; then
# Get plugin file from .puprc versions array that is a PHP file in the base directory
PLUGIN_FILE=$(jq -r '.paths.versions[] | select(.file | test("^[^/]+\\.php$")) | .file' .puprc)

if [ -f "$PLUGIN_FILE" ]; then
sed -i "s/Requires at least: [0-9.]*/Requires at least: $MIN_VERSION/" "$PLUGIN_FILE"
echo "* Updated \`$PLUGIN_FILE\`" >> $GITHUB_STEP_SUMMARY
fi
fi

# Update tests-php.yml and other workflow files if minimum version is being updated (skips self)
if [ "${{ github.event.inputs.update_min_version }}" = "yes" ] && [ -d ".github/workflows" ]; then
for wf in .github/workflows/*.yml; do
[ "$(basename "$wf")" = "update-wp-version.yml" ] && continue
sed -i "s/-wp core update --force --version=[0-9.]*/wp core update --force --version=$MIN_VERSION/" "$wf"
echo "* Updated \`$wf\`" >> $GITHUB_STEP_SUMMARY
done
fi

- name: Create Pull Request
uses: peter-evans/create-pull-request@v6
id: cpr
with:
token: ${{ secrets.GHA_BOT_TOKEN_MANAGER }}
base: ${{ github.ref_name }}
branch: ${{ steps.create-branch.outputs.branch_name }}
title: "[BOT] Update WordPress version requirements"
body: |
This PR updates the WordPress version requirements:

- Sets tested up to version to ${{ github.event.inputs.tested_up_to }}
${{ github.event.inputs.update_min_version == 'yes' && format('* Sets minimum required version to {0}', steps.update-versions.outputs.MIN_VERSION) || '* Keeps minimum required version unchanged' }}

This is an automated PR created by ${{ github.actor }}.
Generated by: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}
[skip-changelog] [skip-lint] [skip-phpcs]
labels: "automation"
commit-message: |
Update WordPress version requirements

- Set tested up to version to ${{ github.event.inputs.tested_up_to }}
${{ github.event.inputs.update_min_version == 'yes' && format('* Set minimum required version to {0}', steps.update-versions.outputs.MIN_VERSION) || '* Kept minimum required version unchanged' }}

This is an automated PR created by ${{ github.actor }}.
Generated by: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}

- name: Check outputs
if: ${{ steps.cpr.outputs.pull-request-number }}
run: |
echo "## Pull Request" >> $GITHUB_STEP_SUMMARY
echo "* Number - ${{ steps.cpr.outputs.pull-request-number }}" >> $GITHUB_STEP_SUMMARY
echo "* URL - [${{ steps.cpr.outputs.pull-request-url }}](${{ steps.cpr.outputs.pull-request-url }})" >> $GITHUB_STEP_SUMMARY
2 changes: 1 addition & 1 deletion bin/check-changelog.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env bash

# npm/@stellarwp/changelogger variant of check-changelog.sh.
# Uses @stellarwp/changelogger (npm) instead of jetpack-changelogger (composer).

BASE=${1-origin/main}
HEAD=${2-HEAD}
Expand Down
2 changes: 1 addition & 1 deletion bin/process-changelog.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env bash

# npm/@stellarwp/changelogger variant of process-changelog.sh.
# Uses @stellarwp/changelogger (npm) instead of jetpack-changelogger (composer).
#
# @stellarwp/changelogger's `write` command merges new entries into an existing version
# section (matched by header) instead of duplicating the header, and it updates every
Expand Down
Loading