All checks were successful
Create Release Package / build-release (push) Successful in 1m21s
- Main plugin file with PHP 8.3+ and WordPress 6.0+ version checks - Plugin singleton class with admin menu and settings pages - License Manager integration with SecureLicenseClient - License settings tab with validation and activation - Admin CSS and JavaScript for license management - Gitea CI/CD workflow for automated releases - Documentation: README.md, PLAN.md, CHANGELOG.md, CLAUDE.md - Composer dependencies: Twig 3.0, license client - Git submodule for wc-licensed-product-client library Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
231 lines
8.3 KiB
YAML
231 lines
8.3 KiB
YAML
name: Create Release Package
|
|
|
|
on:
|
|
push:
|
|
tags:
|
|
- 'v*'
|
|
|
|
jobs:
|
|
build-release:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Checkout code
|
|
uses: actions/checkout@v4
|
|
with:
|
|
submodules: recursive
|
|
|
|
- name: Setup PHP
|
|
uses: shivammathur/setup-php@v2
|
|
with:
|
|
php-version: '8.3'
|
|
extensions: mbstring, xml, zip, intl, gettext
|
|
tools: composer:v2
|
|
|
|
- name: Get version from tag
|
|
id: version
|
|
run: |
|
|
VERSION=${GITHUB_REF_NAME#v}
|
|
echo "version=$VERSION" >> $GITHUB_OUTPUT
|
|
echo "Building version: $VERSION"
|
|
|
|
- name: Validate composer.json
|
|
run: composer validate --no-check-lock --no-check-all
|
|
|
|
- name: Install Composer dependencies (production)
|
|
run: |
|
|
composer config platform.php 8.3.0
|
|
composer install --no-dev --optimize-autoloader --no-interaction
|
|
|
|
- name: Fix vendor symlink
|
|
run: |
|
|
# If client is a symlink, replace with actual files
|
|
if [ -L "vendor/magdev/wc-licensed-product-client" ]; then
|
|
echo "Found symlink, replacing with actual files..."
|
|
TARGET=$(readlink -f vendor/magdev/wc-licensed-product-client)
|
|
rm vendor/magdev/wc-licensed-product-client
|
|
cp -r "$TARGET" vendor/magdev/wc-licensed-product-client
|
|
fi
|
|
ls -la vendor/magdev/
|
|
|
|
- name: Install gettext
|
|
run: apt-get update && apt-get install -y gettext
|
|
|
|
- name: Compile translations
|
|
run: |
|
|
for po in languages/*.po; do
|
|
if [ -f "$po" ]; then
|
|
mo="${po%.po}.mo"
|
|
echo "Compiling $po to $mo"
|
|
msgfmt -o "$mo" "$po"
|
|
fi
|
|
done
|
|
|
|
- name: Verify plugin version matches tag
|
|
run: |
|
|
PLUGIN_VERSION=$(grep -oP "Version:\s*\K[0-9]+\.[0-9]+\.[0-9]+" wp-bnb.php | head -1)
|
|
TAG_VERSION=${{ steps.version.outputs.version }}
|
|
if [ "$PLUGIN_VERSION" != "$TAG_VERSION" ]; then
|
|
echo "Error: Plugin version ($PLUGIN_VERSION) does not match tag version ($TAG_VERSION)"
|
|
exit 1
|
|
fi
|
|
echo "Version verified: $PLUGIN_VERSION"
|
|
|
|
- name: Create release directory
|
|
run: mkdir -p releases
|
|
|
|
- name: Build release package
|
|
run: |
|
|
VERSION=${{ steps.version.outputs.version }}
|
|
PLUGIN_NAME="wp-bnb"
|
|
RELEASE_FILE="releases/${PLUGIN_NAME}-${VERSION}.zip"
|
|
|
|
cd ..
|
|
zip -r "${PLUGIN_NAME}/${RELEASE_FILE}" "${PLUGIN_NAME}" \
|
|
-x "${PLUGIN_NAME}/.git/*" \
|
|
-x "${PLUGIN_NAME}/.gitea/*" \
|
|
-x "${PLUGIN_NAME}/.github/*" \
|
|
-x "${PLUGIN_NAME}/.vscode/*" \
|
|
-x "${PLUGIN_NAME}/.claude/*" \
|
|
-x "${PLUGIN_NAME}/CLAUDE.md" \
|
|
-x "${PLUGIN_NAME}/PLAN.md" \
|
|
-x "${PLUGIN_NAME}/wp-core" \
|
|
-x "${PLUGIN_NAME}/wp-core/*" \
|
|
-x "${PLUGIN_NAME}/wp-plugins" \
|
|
-x "${PLUGIN_NAME}/wp-plugins/*" \
|
|
-x "${PLUGIN_NAME}/releases/*" \
|
|
-x "${PLUGIN_NAME}/cache/*" \
|
|
-x "${PLUGIN_NAME}/composer.lock" \
|
|
-x "${PLUGIN_NAME}/*.log" \
|
|
-x "${PLUGIN_NAME}/.gitignore" \
|
|
-x "${PLUGIN_NAME}/.gitmodules" \
|
|
-x "${PLUGIN_NAME}/.editorconfig" \
|
|
-x "${PLUGIN_NAME}/phpcs.xml*" \
|
|
-x "${PLUGIN_NAME}/phpunit.xml*" \
|
|
-x "${PLUGIN_NAME}/tests/*" \
|
|
-x "${PLUGIN_NAME}/*.po~" \
|
|
-x "${PLUGIN_NAME}/*.bak" \
|
|
-x "${PLUGIN_NAME}/lib/*" \
|
|
-x "${PLUGIN_NAME}/lib/*/.git/*" \
|
|
-x "${PLUGIN_NAME}/vendor/magdev/*/.git/*" \
|
|
-x "${PLUGIN_NAME}/vendor/magdev/*/CLAUDE.md" \
|
|
-x "*.DS_Store"
|
|
|
|
cd "${PLUGIN_NAME}"
|
|
echo "Created: ${RELEASE_FILE}"
|
|
ls -lh "${RELEASE_FILE}"
|
|
|
|
- name: Generate checksums
|
|
run: |
|
|
VERSION=${{ steps.version.outputs.version }}
|
|
PLUGIN_NAME="wp-bnb"
|
|
|
|
cd releases
|
|
sha256sum "${PLUGIN_NAME}-${VERSION}.zip" > "${PLUGIN_NAME}-${VERSION}.zip.sha256"
|
|
echo "SHA256:"
|
|
cat "${PLUGIN_NAME}-${VERSION}.zip.sha256"
|
|
|
|
- name: Verify package structure
|
|
run: |
|
|
set +o pipefail
|
|
VERSION=${{ steps.version.outputs.version }}
|
|
PLUGIN_NAME="wp-bnb"
|
|
|
|
echo "Package contents (first 50 entries):"
|
|
unzip -l "releases/${PLUGIN_NAME}-${VERSION}.zip" | head -50 || true
|
|
|
|
# Verify main plugin file exists
|
|
if unzip -l "releases/${PLUGIN_NAME}-${VERSION}.zip" | grep -q "${PLUGIN_NAME}/${PLUGIN_NAME}.php"; then
|
|
echo "Main plugin file: OK"
|
|
else
|
|
echo "ERROR: Main plugin file not found!"
|
|
exit 1
|
|
fi
|
|
|
|
# Verify vendor directory included
|
|
if unzip -l "releases/${PLUGIN_NAME}-${VERSION}.zip" | grep -q "${PLUGIN_NAME}/vendor/"; then
|
|
echo "Vendor directory: OK"
|
|
else
|
|
echo "ERROR: Vendor directory not found!"
|
|
exit 1
|
|
fi
|
|
|
|
# Verify lib directory excluded
|
|
if unzip -l "releases/${PLUGIN_NAME}-${VERSION}.zip" | grep -q "${PLUGIN_NAME}/lib/"; then
|
|
echo "WARNING: lib/ directory should be excluded"
|
|
else
|
|
echo "lib/ excluded: OK"
|
|
fi
|
|
|
|
- name: Extract changelog for release notes
|
|
id: changelog
|
|
run: |
|
|
VERSION=${{ steps.version.outputs.version }}
|
|
NOTES=$(sed -n "/^## \[${VERSION}\]/,/^## \[/p" CHANGELOG.md | sed '$ d' | tail -n +2)
|
|
if [ -z "$NOTES" ]; then
|
|
NOTES="Release version ${VERSION}"
|
|
fi
|
|
echo "$NOTES" > release_notes.txt
|
|
echo "Release notes extracted"
|
|
|
|
- name: Create Gitea Release
|
|
env:
|
|
GITEA_TOKEN: ${{ secrets.SRC_GITEA_TOKEN }}
|
|
run: |
|
|
VERSION=${{ steps.version.outputs.version }}
|
|
TAG_NAME=${{ github.ref_name }}
|
|
PLUGIN_NAME="wp-bnb"
|
|
|
|
PRERELEASE="false"
|
|
if [[ "$TAG_NAME" == *-* ]]; then
|
|
PRERELEASE="true"
|
|
fi
|
|
|
|
BODY=$(cat release_notes.txt)
|
|
|
|
# Check if release already exists and delete it
|
|
EXISTING_RELEASE=$(curl -s \
|
|
-H "Authorization: token ${GITEA_TOKEN}" \
|
|
"${GITHUB_SERVER_URL}/api/v1/repos/${GITHUB_REPOSITORY}/releases/tags/${TAG_NAME}")
|
|
|
|
EXISTING_ID=$(echo "$EXISTING_RELEASE" | jq -r '.id // empty')
|
|
if [ -n "$EXISTING_ID" ] && [ "$EXISTING_ID" != "null" ]; then
|
|
echo "Deleting existing release ID: $EXISTING_ID"
|
|
curl -s -X DELETE \
|
|
-H "Authorization: token ${GITEA_TOKEN}" \
|
|
"${GITHUB_SERVER_URL}/api/v1/repos/${GITHUB_REPOSITORY}/releases/${EXISTING_ID}"
|
|
echo "Existing release deleted"
|
|
fi
|
|
|
|
# Create release via Gitea API
|
|
RELEASE_RESPONSE=$(curl -s -X POST \
|
|
-H "Authorization: token ${GITEA_TOKEN}" \
|
|
-H "Content-Type: application/json" \
|
|
-d "{\"tag_name\": \"${TAG_NAME}\", \"name\": \"Release ${VERSION}\", \"body\": $(echo "$BODY" | jq -Rs .), \"draft\": false, \"prerelease\": ${PRERELEASE}}" \
|
|
"${GITHUB_SERVER_URL}/api/v1/repos/${GITHUB_REPOSITORY}/releases")
|
|
|
|
RELEASE_ID=$(echo "$RELEASE_RESPONSE" | jq -r '.id')
|
|
|
|
if [ "$RELEASE_ID" == "null" ] || [ -z "$RELEASE_ID" ]; then
|
|
echo "Failed to create release:"
|
|
echo "$RELEASE_RESPONSE"
|
|
exit 1
|
|
fi
|
|
|
|
echo "Created release ID: $RELEASE_ID"
|
|
|
|
# Upload release assets
|
|
for file in "releases/${PLUGIN_NAME}-${VERSION}.zip" "releases/${PLUGIN_NAME}-${VERSION}.zip.sha256"; do
|
|
if [ -f "$file" ]; then
|
|
FILENAME=$(basename "$file")
|
|
echo "Uploading $FILENAME..."
|
|
curl -s -X POST \
|
|
-H "Authorization: token ${GITEA_TOKEN}" \
|
|
-H "Content-Type: application/octet-stream" \
|
|
--data-binary "@$file" \
|
|
"${GITHUB_SERVER_URL}/api/v1/repos/${GITHUB_REPOSITORY}/releases/${RELEASE_ID}/assets?name=${FILENAME}"
|
|
echo "Uploaded $FILENAME"
|
|
fi
|
|
done
|
|
|
|
echo "Release created: ${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}/releases/tag/${TAG_NAME}"
|