Add efficient build workflow with npm scripts for translations, CSS/JS processing, and automated release
This commit is contained in:
77
.github/workflows/release.yml
vendored
77
.github/workflows/release.yml
vendored
@ -20,7 +20,7 @@ jobs:
|
||||
with:
|
||||
php-version: '7.4'
|
||||
extensions: mbstring, intl, curl
|
||||
tools: composer
|
||||
tools: composer, wp-cli
|
||||
|
||||
- name: Get the version
|
||||
id: get_version
|
||||
@ -30,30 +30,41 @@ jobs:
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: '18'
|
||||
cache: 'npm'
|
||||
|
||||
- name: Install dependencies
|
||||
- name: Install PHP dependencies
|
||||
run: composer install --no-dev --optimize-autoloader
|
||||
|
||||
- name: Install Node dependencies
|
||||
run: npm ci
|
||||
|
||||
- name: Verify version matches
|
||||
run: |
|
||||
composer install --no-dev --optimize-autoloader
|
||||
npm ci
|
||||
WP_VERSION=$(grep -m 1 "Version: " wp-multisite-waas.php | awk -F' ' '{print $2}')
|
||||
README_VERSION=$(grep -m 1 "Stable tag: " readme.txt | awk -F' ' '{print $3}')
|
||||
PKG_VERSION=$(node -p "require('./package.json').version")
|
||||
|
||||
if [ "$WP_VERSION" != "${{ env.VERSION }}" ] || [ "$README_VERSION" != "${{ env.VERSION }}" ] || [ "$PKG_VERSION" != "${{ env.VERSION }}" ]; then
|
||||
echo "Error: Version mismatch detected!"
|
||||
echo "Tag version: ${{ env.VERSION }}"
|
||||
echo "Plugin version: $WP_VERSION"
|
||||
echo "readme.txt version: $README_VERSION"
|
||||
echo "package.json version: $PKG_VERSION"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "All version numbers match: ${{ env.VERSION }}"
|
||||
|
||||
- name: Build assets
|
||||
run: npm run build
|
||||
- name: Generate translation files
|
||||
run: npm run translations
|
||||
|
||||
- name: Create build directory
|
||||
- name: Process CSS and JS
|
||||
run: |
|
||||
mkdir -p build/wp-multisite-waas
|
||||
cp -r $(ls -A | grep -v "^build$" | grep -v "^\.git$" | grep -v "^node_modules$" | xargs) build/wp-multisite-waas/
|
||||
|
||||
- name: Remove development files
|
||||
run: |
|
||||
cd build/wp-multisite-waas
|
||||
rm -rf .github .gitignore composer.json composer.lock package.json package-lock.json phpunit.xml webpack.config.js node_modules tests .git
|
||||
find . -name "*.map" -type f -delete
|
||||
npm run css
|
||||
npm run js
|
||||
|
||||
- name: Create ZIP file
|
||||
run: |
|
||||
cd build
|
||||
zip -r wp-multisite-waas-${{ env.VERSION }}.zip wp-multisite-waas
|
||||
run: npm run zip
|
||||
|
||||
- name: Create Release
|
||||
id: create_release
|
||||
@ -64,6 +75,32 @@ jobs:
|
||||
draft: false
|
||||
prerelease: false
|
||||
body: |
|
||||
WP Multisite WaaS ${{ env.VERSION }}
|
||||
# WP Multisite WaaS ${{ env.VERSION }}
|
||||
|
||||
This is an automated release. Please refer to the changelog in readme.txt for details.
|
||||
## What's Changed
|
||||
|
||||
For a complete list of changes, please refer to the [changelog](https://github.com/wpallstars/wp-multisite-waas/blob/main/readme.txt).
|
||||
|
||||
## Installation
|
||||
|
||||
1. Download the ZIP file from this release
|
||||
2. Upload and activate the plugin in your WordPress Network installation
|
||||
3. Follow the setup wizard to configure the plugin
|
||||
|
||||
## Notes
|
||||
|
||||
- Compatible with WordPress 5.3+
|
||||
- Requires PHP 7.4.30+
|
||||
- Always backup your site before upgrading
|
||||
|
||||
- name: Send notification on success
|
||||
if: success()
|
||||
uses: rtCamp/action-slack-notify@v2
|
||||
env:
|
||||
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}
|
||||
SLACK_CHANNEL: releases
|
||||
SLACK_COLOR: good
|
||||
SLACK_MESSAGE: "🚀 WP Multisite WaaS ${{ env.VERSION }} has been released! https://github.com/wpallstars/wp-multisite-waas/releases"
|
||||
SLACK_TITLE: New Release
|
||||
SLACK_USERNAME: GitHub
|
||||
SLACK_ICON_EMOJI: ":github:"
|
Reference in New Issue
Block a user