updates
Build and Release WordPress Plugin / build-release (push) Failing after 42s

This commit is contained in:
mydev committed 2026-11-25 04:27:24 +02:00
1 parent 5837c330d0
commit 07867efd5a
2 files changed
+128 -55

No files matched your search

+124 -53
View File
@@ -1,95 +1,166 @@
name: Build WordPress Plugin (XML-driven)
name: Build and Release WordPress Plugin
on: on:
push: push:
branches: branches:
- main - main
workflow_dispatch:
permissions:
contents: write
jobs: jobs:
build-release: build-release:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
# 1. Checkout
- name: Checkout - name: Checkout
uses: actions/checkout@v4 uses: actions/checkout@v4
- name: Install XML tools and zip # 2. Install dependencies
- name: Install dependencies
run: | run: |
sudo apt-get update sudo apt-get update
sudo apt-get install -y libxml2-utils zip sudo apt-get install -y \
php-cli \
zip \
unzip \
rsync \
curl
# ------------------------------------------------------------ # 3. Extract plugin metadata
# 1. Extract metadata from plugin.xml - name: Extract plugin metadata
# ------------------------------------------------------------
- name: Extract metadata from plugin.xml
id: meta
run: | run: |
if [ ! -f plugin.xml ]; then set -euo pipefail
echo "❌ plugin.xml not found!" >&2
exit 1
fi
NAME=$(xmllint --xpath "string(//name)" plugin.xml) MAIN_FILE="advanced-seo-keywords.php"
VERSION=v$(xmllint --xpath "string(//version)" plugin.xml) SLUG="advanced-seo-keywords"
test -f "$MAIN_FILE"
NAME=$(sed -nE \
's/^[[:space:]]*\*[[:space:]]*Plugin Name:[[:space:]]*(.*)/\1/p' \
"$MAIN_FILE" | head -n1)
VERSION=$(sed -nE \
's/^[[:space:]]*\*[[:space:]]*Version:[[:space:]]*([^[:space:]]+).*/\1/p' \
"$MAIN_FILE" | head -n1)
if [ -z "$NAME" ] || [ -z "$VERSION" ]; then if [ -z "$NAME" ] || [ -z "$VERSION" ]; then
echo "❌ Could not extract <name> or <version> from plugin.xml" >&2 echo "Plugin metadata missing"
exit 1 exit 1
fi fi
# Sanitize the name to a safe slug (lowercase, replace non-alnum with '-') if ! [[ "$VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
SLUG=$(echo "$NAME" | tr '[:upper:]' '[:lower:]' | sed -E 's/[^a-z0-9]+/-/g; s/^-+//; s/-+$//') echo "Invalid version: $VERSION"
exit 1
fi
echo "PLUGIN_NAME=$NAME" >> $GITHUB_ENV echo "PLUGIN_NAME=$NAME" >> "$GITHUB_ENV"
echo "SLUG=$SLUG" >> $GITHUB_ENV echo "VERSION=v$VERSION" >> "$GITHUB_ENV"
echo "VERSION=$VERSION" >> $GITHUB_ENV echo "SLUG=$SLUG" >> "$GITHUB_ENV"
echo "FILENAME=${SLUG}-${VERSION}.zip" >> $GITHUB_ENV echo "FILENAME=$SLUG-v$VERSION.zip" >> "$GITHUB_ENV"
echo "✅ Plugin: $NAME, Slug: $SLUG, Version: $VERSION" echo "Plugin: $NAME"
echo "Version: $VERSION"
echo "Slug: $SLUG"
# ------------------------------------------------------------ # 4. Validate PHP
# 2. Prepare package (copy everything EXCEPT plugin.xml, .git, .github) - name: Validate PHP
# ------------------------------------------------------------ run: |
set -euo pipefail
php -l advanced-seo-keywords.php
# 5. Prepare package
- name: Prepare package - name: Prepare package
run: | run: |
mkdir -p build/"$SLUG" set -euo pipefail
# Copy everything except .git, .github, and plugin.xml
find . -maxdepth 1 -not -name "." -not -name ".git" -not -name ".github" -not -name "plugin.xml" -exec cp -r {} build/"$SLUG"/ \;
# ------------------------------------------------------------ rm -rf build
# 3. Build the zip mkdir -p "build/$SLUG"
# ------------------------------------------------------------
- name: Build plugin zip rsync -a \
--exclude='/.git/' \
--exclude='/.gitea/' \
--exclude='/.github/' \
--exclude='/build/' \
--exclude='/plugin.xml' \
--exclude='/node_modules/' \
--exclude='/tests/' \
./ "build/$SLUG/"
test -f "build/$SLUG/advanced-seo-keywords.php"
# 6. Build ZIP
- name: Build ZIP
run: | run: |
set -euo pipefail
cd build cd build
zip -r "../$FILENAME" "$SLUG" zip -qr "../$FILENAME" "$SLUG"
cd .. cd ..
# ------------------------------------------------------------ test -s "$FILENAME"
# 4. Install tea CLI unzip -t "$FILENAME"
# ------------------------------------------------------------
- name: Install tea CLI
run: |
curl -L https://dl.gitea.io/tea/main/tea-main-linux-amd64 -o tea
chmod +x tea
sudo mv tea /usr/local/bin/
# ------------------------------------------------------------ # 7. Verify package
# 5. Configure tea - name: Verify package
# ------------------------------------------------------------
- name: Configure tea
run: | run: |
set -euo pipefail
unzip -l "$FILENAME"
unzip -p "$FILENAME" \
"$SLUG/advanced-seo-keywords.php" \
| grep -E 'Plugin Name:|Version:'
# 8. Install Gitea CLI
- name: Install tea
run: |
set -euo pipefail
curl -fL \
https://dl.gitea.io/tea/main/tea-main-linux-amd64 \
-o tea
chmod +x tea
sudo install tea /usr/local/bin/tea
tea --version
# 9. Configure Gitea authentication
- name: Configure Gitea
env:
GITEA_URL: ${{ vars.SERVER_URL }}
GITEA_TOKEN: ${{ secrets.OC3_EXTENSION_RELEASE_TOKEN }}
run: |
set -euo pipefail
test -n "$GITEA_URL"
test -n "$GITEA_TOKEN"
tea login add \ tea login add \
--name gitea \ --name gitea \
--url "${{ vars.SERVER_URL }}" \ --url "$GITEA_URL" \
--token "${{ secrets.OC3_EXTENSION_RELEASE_TOKEN }}" --token "$GITEA_TOKEN"
# ------------------------------------------------------------ # 10. Create release and upload ZIP
# 6. Create (or force‑update) release - name: Publish release
# ------------------------------------------------------------
- name: Create release
run: | run: |
set -euo pipefail
tea release create "$VERSION" \ tea release create "$VERSION" \
--title "${PLUGIN_NAME}_${VERSION}" \ --title "$PLUGIN_NAME $VERSION" \
--asset "${FILENAME}" \ --note "Automated WordPress plugin release $VERSION" \
--asset "$FILENAME" \
--force --force
# 11. Report
- name: Release summary
run: |
echo "Release successfully submitted."
echo "Version: $VERSION"
echo "Asset: $FILENAME"
echo "Repository: $GITHUB_REPOSITORY"
+4 -2
View File
@@ -1,4 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<plugin> <plugin>
<name>Advanced SEO Meta + AI FAQ Schema</name> <name>Advanced SEO Meta + AI FAQ Schema</name>
<version>3.0.0</version> <version>4.1.0</version>
<slug>advanced-seo-keywords</slug>
</plugin> </plugin>