GitHub CLI (gh) for WordPress Plugin Release Automation

The GitHub CLI (gh) turns release workflows into scriptable one-liners — creating releases, uploading assets, managing pull requests, and triggering Actions workflows from the terminal. For WordPress plugin maintainers it replaces clicking through the GitHub UI entirely.

Problem: Publishing a WordPress plugin release requires switching between the GitHub UI, the terminal, and the plugin's SVN repository — tagging the release, writing release notes, uploading assets, and updating the changelog are separate manual steps with no single automated workflow.

Solution: Use the GitHub CLI (gh) to automate the release pipeline: gh release create v1.2.3 --generate-notes creates a release from the tag and auto-generates notes from merged PRs. Combine with a GitHub Actions workflow that triggers on the release event to build, test, and deploy the plugin to WordPress.org SVN automatically.

The examples below create a GitHub release with a built plugin zip, auto-generate release notes from merged pull requests, and trigger a deployment workflow via gh workflow run.

# Install GitHub CLI
brew install gh            # macOS
sudo apt install gh        # Ubuntu/Debian

# Authenticate
gh auth login

# ── CREATING A RELEASE ──

# 1. Build the plugin zip first
VERSION="1.4.2"
PLUGIN="my-woo-plugin"
mkdir -p dist/${PLUGIN}
rsync -r --exclude='.git' --exclude='node_modules' --exclude='tests' \
         --exclude='.github' --exclude='*.map' \
         ./ dist/${PLUGIN}/
cd dist && zip -r ../${PLUGIN}-${VERSION}.zip ${PLUGIN}/ && cd ..

# 2. Create release with auto-generated notes from merged PRs
gh release create "v${VERSION}" \
    "${PLUGIN}-${VERSION}.zip" \
    --title "v${VERSION}" \
    --generate-notes \
    --latest

# 3. Or write a custom release note manually
gh release create "v${VERSION}" \
    "${PLUGIN}-${VERSION}.zip" \
    --title "v${VERSION}" \
    --notes "## What's New
- Fix cart nonce expiry on checkout (#142)
- Add support for PHP 8.3 (#138)
- Improve performance of order query (#131)"

# 4. Upload an additional asset to an existing release
gh release upload "v${VERSION}" ./docs/changelog.pdf --clobber

Manage pull requests and trigger workflows:

# ── PULL REQUEST WORKFLOW ──

# Create a PR from current branch
gh pr create \
    --title "feat(cart): add persistent cart for guests" \
    --body "Closes #157. Stores cart data in a cookie for 30 days." \
    --base main \
    --label "enhancement"

# List open PRs
gh pr list --label "bug"

# Merge a PR and delete the branch
gh pr merge 162 --squash --delete-branch

# ── TRIGGERING WORKFLOWS ──

# Run a deploy workflow with inputs
gh workflow run deploy.yml \
    --ref main \
    --field environment=production \
    --field version=${VERSION}

# Watch the workflow run in real time
gh run watch

# List recent workflow runs
gh run list --workflow=release.yml --limit=5

# Download artifacts from a workflow run
gh run download 9876543210 --name plugin-zip --dir ./artifacts

# ── REPO MANAGEMENT ──

# View open issues by label
gh issue list --label "wontfix" --state closed

# Create an issue from a template
gh issue create --title "Bug: Checkout fails on iOS Safari" --assignee @me

NOTE: Combine gh release create --generate-notes with Conventional Commits (see git-cliff) to get structured release notes automatically — GitHub groups commits by type when conventional commit subjects are used as PR titles. Run gh auth status to verify token scopes; CI pipelines need the GITHUB_TOKEN secret with contents: write permission.

Leave Comment

Your email address will not be published. Required fields are marked *