Update build_joomla_zip.yml

This commit is contained in:
2025-12-18 17:22:23 -06:00
parent 6c643d7853
commit 93c8d0693e

View File

@@ -25,6 +25,9 @@
# PATH: /.github/workflows/build_joomla_zip.yml
# VERSION: 01.00.00
# BRIEF: Build a Joomla ZIP from /src and optionally attach it to a GitHub Release.
# NOTE: Zips the contents of /src (not the folder) to avoid nested ZIP structures.
# ============================================================================
#
# Script details
# - Builds a ZIP artifact from the repository /src folder.
# - Runs automatically when a GitHub Release is created.
@@ -103,16 +106,18 @@ jobs:
ZIP_BASE="${ZIP_BASE_INPUT}"
else
ZIP_BASE="${REPO_NAME}"
fi
VERSION=""
SUFFIX_INPUT="${{ github.event.inputs.zip_suffix }}"
PRERELEASE_INPUT="${{ github.event.inputs.prerelease }}"
ATTACH_INPUT="${{ github.event.inputs.attach_to_release }}"
if [ "${GITHUB_EVENT_NAME}" = "release" ]; then
ATTACH="true"
TAG_NAME="${{ github.event.release.tag_name }}"
VERSION="${TAG_NAME##*/}"
PRERELEASE="${{ github.event.release.prerelease }}"
else
if [ "${ATTACH_INPUT}" = "true" ]; then
ATTACH="true"
@@ -138,6 +143,19 @@ jobs:
TAG_NAME="dev/${VERSION}"
fi
if [ "${PRERELEASE_INPUT}" = "true" ]; then
PRERELEASE="true"
else
PRERELEASE="false"
fi
fi
if [ -n "${VERSION}" ]; then
:
else
echo "ERROR: VERSION could not be resolved." >&2
exit 1
fi
if [ -n "${SUFFIX_INPUT}" ]; then
@@ -145,3 +163,68 @@ jobs:
else
ZIP_NAME="${ZIP_BASE}-${VERSION}.zip"
fi
echo "zip_name=${ZIP_NAME}" >> "$GITHUB_OUTPUT"
echo "attach=${ATTACH}" >> "$GITHUB_OUTPUT"
echo "tag_name=${TAG_NAME}" >> "$GITHUB_OUTPUT"
echo "version=${VERSION}" >> "$GITHUB_OUTPUT"
echo "prerelease=${PRERELEASE}" >> "$GITHUB_OUTPUT"
echo "Resolved parameters:" >&2
echo "- ZIP_NAME: ${ZIP_NAME}" >&2
echo "- ATTACH_TO_RELEASE: ${ATTACH}" >&2
echo "- TAG_NAME: ${TAG_NAME}" >&2
echo "- VERSION: ${VERSION}" >&2
echo "- PRERELEASE: ${PRERELEASE}" >&2
- name: Preflight checks
shell: bash
run: |
set -euo pipefail
if [ "${{ steps.params.outputs.attach }}" = "true" ] && [ -z "${{ steps.params.outputs.tag_name }}" ]; then
echo "ERROR: tag_name is required when attach_to_release=true on workflow_dispatch." >&2
echo "Provide 'release_tag' input, or run on a Release created event." >&2
exit 1
fi
echo "src directory listing:" >&2
ls -la src >&2
- name: Build ZIP from src contents
shell: bash
run: |
set -euo pipefail
ZIP_NAME="${{ steps.params.outputs.zip_name }}"
rm -f "${ZIP_NAME}"
# Zip the contents of src, not the folder itself.
# This avoids producing a ZIP with a top-level src/ directory.
( cd src && zip -r -q "../${ZIP_NAME}" . )
if [ ! -f "${ZIP_NAME}" ]; then
echo "ERROR: ZIP build failed. Output file not found: ${ZIP_NAME}" >&2
exit 1
fi
echo "Built ZIP:" >&2
ls -la "${ZIP_NAME}" >&2
- name: Upload build artifact to workflow run
if: steps.params.outputs.attach != 'true'
uses: actions/upload-artifact@v4
with:
name: joomla-zip
path: ${{ steps.params.outputs.zip_name }}
if-no-files-found: error
- name: Attach ZIP to GitHub Release
if: steps.params.outputs.attach == 'true'
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ steps.params.outputs.tag_name }}
prerelease: ${{ steps.params.outputs.prerelease == 'true' }}
files: ${{ steps.params.outputs.zip_name }}
fail_on_unmatched_files: true