Skip to content

Instantly share code, notes, and snippets.

@jack-arturo
Created August 22, 2025 20:58
Show Gist options
  • Save jack-arturo/aedca7b3bf53964863b09939c5d73bcc to your computer and use it in GitHub Desktop.
Save jack-arturo/aedca7b3bf53964863b09939c5d73bcc to your computer and use it in GitHub Desktop.
WP Fusion's release github action Aug 2025
name: Release Build
on:
pull_request:
types: [closed]
branches:
- 'master'
permissions:
contents: write
actions: read
jobs:
build-and-release:
name: Build & Release
runs-on: ubuntu-latest
if: |
github.event.pull_request.merged == true &&
startsWith(github.event.pull_request.head.ref, 'release/')
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.1'
tools: composer, phpstan, phpcs
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
- name: Install Composer dependencies
run: composer install --no-interaction --prefer-dist --optimize-autoloader
- name: Install WP-CLI
run: |
curl -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar
chmod +x wp-cli.phar
sudo mv wp-cli.phar /usr/local/bin/wp
- name: Install Node dependencies
run: npm ci
- name: Build assets
run: npm run build
# - name: Run PHPCS
# run: composer phpcs
# - name: Run PHPStan
# run: composer phpstan
- name: Download WordPress
run: |
cd ..
curl -O https://wordpress.org/latest.zip
unzip -q latest.zip
echo "WordPress downloaded to parent directory"
- name: Install WP-CLI dist-archive command
run: |
cd $GITHUB_WORKSPACE
wp package install wp-cli/dist-archive-command
- name: Extract version from branch name
id: version
run: |
# Extract version from branch name (e.g., release/3.46.7 -> 3.46.7)
BRANCH_NAME="${{ github.event.pull_request.head.ref }}"
VERSION=$(echo "$BRANCH_NAME" | sed 's/^release\///')
echo "version=$VERSION" >> $GITHUB_OUTPUT
echo "Extracted version: $VERSION"
- name: Create ZIP with WP-CLI
run: |
# Run dist-archive from the plugin directory, pointing to WordPress in parent
wp dist-archive . wp-fusion-${{ steps.version.outputs.version }}.zip --path=../wordpress
echo "Created: wp-fusion-${{ steps.version.outputs.version }}.zip"
- name: Create Release
id: create_release
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ steps.version.outputs.version }}
name: Release ${{ steps.version.outputs.version }}
body: "Automated release for version ${{ steps.version.outputs.version }}"
draft: false
prerelease: false
files: ../wp-fusion-${{ steps.version.outputs.version }}.zip
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment