Skip to content

Release Plugin

Release Plugin #4

Workflow file for this run

name: Release Plugin
# Produce a distributable `hey-woo.zip` and publish it as a GitHub Release.
#
# Trigger: manual workflow_dispatch only — tag pushes do NOT trigger this
# workflow; the tag + Release are CREATED by the workflow, not consumed by it.
# This makes the release a deliberate UI action that goes through the full
# build + validation path.
#
# Prerequisites (enforced at runtime, workflow fails fast if not met):
# - The `version` input must match the `Version:` header in hey-woo.php.
# Bump the header on a PR and merge it first, then dispatch this workflow
# with the matching version.
# - The tag `v<version>` must not already exist on the remote.
on:
workflow_dispatch:
inputs:
version:
description: 'Release version, e.g. 0.1.0 (must match the Version header in hey-woo.php)'
required: true
type: string
draft:
description: 'Create the Release as a draft (review/edit before publishing)'
type: boolean
default: false
prerelease:
description: 'Mark the Release as a pre-release'
type: boolean
default: false
permissions:
contents: write # required for softprops/action-gh-release to create the tag + Release
jobs:
release:
name: Build and release
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Validate version input matches plugin header
run: |
# Strip an optional leading 'v' so both "0.1.0" and "v0.1.0" are accepted.
INPUT_VERSION="${{ inputs.version }}"
INPUT_VERSION="${INPUT_VERSION#v}"
HEADER_VERSION="$(awk '/^ \* Version:/ { print $3; exit }' hey-woo.php)"
if [[ -z "${HEADER_VERSION}" ]]; then
echo "ERROR: could not read Version header from hey-woo.php" >&2
exit 1
fi
if [[ "${INPUT_VERSION}" != "${HEADER_VERSION}" ]]; then
echo "ERROR: input version '${INPUT_VERSION}' does not match the Version header ('${HEADER_VERSION}')." >&2
echo " Bump hey-woo.php on a PR first, merge it, then re-run this workflow." >&2
exit 1
fi
echo "VERSION=${INPUT_VERSION}" >> "$GITHUB_ENV"
echo "TAG_NAME=v${INPUT_VERSION}" >> "$GITHUB_ENV"
- name: Verify tag does not already exist
run: |
if git rev-parse -q --verify "refs/tags/${TAG_NAME}" > /dev/null 2>&1; then
echo "ERROR: tag ${TAG_NAME} already exists locally in this checkout" >&2
exit 1
fi
if git ls-remote --exit-code --tags origin "${TAG_NAME}" > /dev/null 2>&1; then
echo "ERROR: tag ${TAG_NAME} already exists on origin" >&2
echo " Either bump the version or delete the existing tag." >&2
exit 1
fi
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'npm'
- name: Install dependencies
run: npm ci
- name: Build plugin zip
run: npm run plugin-zip
- name: Verify zip was produced
run: |
if [ ! -f hey-woo.zip ]; then
echo "ERROR: hey-woo.zip not found" >&2
exit 1
fi
- name: Upload workflow artifact
uses: actions/upload-artifact@v4
with:
name: hey-woo-${{ env.VERSION }}
path: hey-woo.zip
retention-days: 30
- name: Create GitHub Release
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ env.TAG_NAME }}
name: ${{ env.TAG_NAME }}
target_commitish: ${{ github.sha }}
files: hey-woo.zip
generate_release_notes: true
draft: ${{ inputs.draft }}
prerelease: ${{ inputs.prerelease }}