Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Triggers when a release is published in the GitHub UI | |
name: Build and Upload Release Asset | |
on: | |
release: | |
types: [published] # Trigger when a release is published | |
jobs: | |
build-and-upload: | |
name: Build and Upload Asset | |
runs-on: ubuntu-latest | |
permissions: | |
contents: write | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
with: | |
# Checkout the specific tag associated with the release | |
ref: ${{ github.event.release.tag_name }} | |
fetch-depth: 0 | |
- name: Set up Node.js | |
uses: actions/setup-node@v4 | |
with: | |
node-version: '20.x' | |
cache: 'npm' | |
registry-url: 'https://registry.npmjs.org' | |
- name: Set up PHP | |
uses: shivammathur/setup-php@v2 | |
with: | |
php-version: '7.4' | |
tools: composer:v2 | |
- name: Install dependencies | |
run: | | |
npm ci | |
composer install --no-dev --optimize-autoloader | |
- name: Build project | |
run: npm run build | |
- name: Create plugin zip | |
run: npm run plugin-zip | |
- name: Create demo plugin zip | |
run: npm run plugin-zip -w wp-feature-api-agent | |
- name: Upload Main Plugin Release Asset | |
uses: actions/upload-release-asset@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
upload_url: ${{ github.event.release.upload_url }} # Get upload URL from the release event | |
asset_path: ./wp-feature-api.zip | |
asset_name: wp-feature-api.zip | |
asset_content_type: application/zip | |
- name: Upload Demo Plugin Release Asset | |
uses: actions/upload-release-asset@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
upload_url: ${{ github.event.release.upload_url }} | |
asset_path: ./demo/wp-feature-api-agent/wp-feature-api-agent.zip | |
asset_name: wp-feature-api-agent.zip | |
asset_content_type: application/zip | |
# Update release tag to include build files for Packagist/Composer | |
- name: Add build files to release tag | |
run: | | |
# Configure git for GitHub Actions | |
git config --global user.name "GitHub Actions Bot" | |
git config --global user.email "[email protected]" | |
# Make sure we're on the release tag | |
git checkout ${{ github.event.release.tag_name }} | |
# Add build files to the commit (force add since they're in .gitignore) | |
git add -f build/ | |
# Commit the build files | |
git commit -m "Add build files for Composer package distribution" | |
# Force-update the tag to include the build files | |
git tag -f ${{ github.event.release.tag_name }} | |
# Push the updated tag | |
git push origin ${{ github.event.release.tag_name }} --force | |
echo "Release tag ${{ github.event.release.tag_name }} has been updated to include build files for Packagist" | |
# NPM package publishing | |
- name: Publish NPM packages | |
run: | | |
# First build all packages to ensure dependencies are satisfied | |
npm run build | |
# Publish client package to NPM if configured | |
if [ -d "packages/client" ]; then | |
cd packages/client | |
npm publish --access public | |
fi | |
env: | |
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} |