Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
92 changes: 81 additions & 11 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,20 +1,79 @@
name: Release
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:
push:
tags:
- 'v*'
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:
build:
name: Build plugin zip
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:
Expand All @@ -27,16 +86,27 @@ jobs:
- name: Build plugin zip
run: npm run plugin-zip

- name: Upload zip artifact
- 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
name: hey-woo-${{ env.VERSION }}
path: hey-woo.zip
retention-days: 7
retention-days: 30

- name: Create GitHub release
if: startsWith(github.ref, 'refs/tags/')
- 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 }}
Loading