Skip to content

Release

Release #14

Workflow file for this run

name: Release
on:
repository_dispatch:
types: [openapi-updated]
workflow_dispatch:
inputs:
version_bump:
description: 'patch | minor | major'
required: false
default: 'patch'
jobs:
release:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v6
with:
token: ${{ secrets.GITHUB_TOKEN }}
fetch-depth: 0
- uses: shivammathur/setup-php@v2
with:
php-version: '8.3'
extensions: mysqli, zip, gd
tools: composer
coverage: none
# Install dev deps for verification (PHPUnit, PHPStan, PHPCS).
# Re-installed without --dev right before deploy.
- run: composer install --prefer-dist
- uses: actions/setup-node@v6
with:
node-version: '24'
cache: 'npm'
- run: npm ci
- name: Regenerate from live OpenAPI
run: npm run generate
- name: Check if spec changed
id: diff
run: |
if git diff --quiet specs/openapi.json src/Generated blocks/generated; then
echo "changed=false" >> $GITHUB_OUTPUT
else
echo "changed=true" >> $GITHUB_OUTPUT
fi
- name: Lint
if: steps.diff.outputs.changed == 'true' || github.event_name == 'workflow_dispatch'
run: vendor/bin/phpcs --standard=phpcs.xml.dist
- name: Static analysis
if: steps.diff.outputs.changed == 'true' || github.event_name == 'workflow_dispatch'
run: vendor/bin/phpstan analyze --no-progress --memory-limit=1G
- name: Build blocks
if: steps.diff.outputs.changed == 'true' || github.event_name == 'workflow_dispatch'
run: npm run build:all
- name: PHPUnit
if: steps.diff.outputs.changed == 'true' || github.event_name == 'workflow_dispatch'
env:
DB_HOST: 127.0.0.1
run: |
sudo apt-get install -y -qq subversion
sudo systemctl start mysql
mysql -uroot -proot -e "CREATE DATABASE IF NOT EXISTS wordpress_test;"
bash bin/install-wp-tests.sh wordpress_test root root 127.0.0.1 latest true
vendor/bin/phpunit
- name: Reinstall composer without dev deps for shipped vendor/
if: steps.diff.outputs.changed == 'true' || github.event_name == 'workflow_dispatch'
run: composer install --no-dev --optimize-autoloader --prefer-dist
- name: Bump version
if: steps.diff.outputs.changed == 'true' || github.event_name == 'workflow_dispatch'
id: bump
run: |
BUMP="${{ github.event.inputs.version_bump || 'patch' }}"
npm version "$BUMP" --no-git-tag-version
VERSION=$(node -p "require('./package.json').version")
echo "version=$VERSION" >> $GITHUB_OUTPUT
sed -i "s/^\(\s*\*\s*Version:\s*\).*/\1$VERSION/" roxyapi.php
sed -i "s/const ROXYAPI_VERSION\s*=\s*'[^']*';/const ROXYAPI_VERSION = '$VERSION';/" roxyapi.php
sed -i "s/^Stable tag:.*$/Stable tag: $VERSION/" readme.txt
- name: Commit, tag, push
if: steps.diff.outputs.changed == 'true' || github.event_name == 'workflow_dispatch'
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
VERSION="${{ steps.bump.outputs.version }}"
git add .
git commit -m "release: v$VERSION"
git tag "v$VERSION"
git push --follow-tags
- name: Deploy to WordPress.org
if: steps.diff.outputs.changed == 'true' || github.event_name == 'workflow_dispatch'
id: deploy
uses: 10up/action-wordpress-plugin-deploy@stable
with:
generate-zip: true
env:
SVN_USERNAME: ${{ secrets.SVN_USERNAME }}
SVN_PASSWORD: ${{ secrets.SVN_PASSWORD }}
SLUG: roxyapi
VERSION: ${{ steps.bump.outputs.version }}
- name: Attach zip to GitHub release
if: steps.diff.outputs.changed == 'true' || github.event_name == 'workflow_dispatch'
uses: softprops/action-gh-release@v3
with:
tag_name: v${{ steps.bump.outputs.version }}
files: ${{ steps.deploy.outputs.zip-path }}
generate_release_notes: true
- name: No changes
if: steps.diff.outputs.changed == 'false' && github.event_name != 'workflow_dispatch'
run: echo "OpenAPI spec unchanged. Nothing to release."