Compare commits
11
Commits
da01a1fb4e
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4e9d418e04 | ||
|
|
412844bb1f | ||
|
|
da3b582a63 | ||
|
|
9019cf48d3 | ||
|
|
4e54ecf721 | ||
|
|
5b9ad90ed7 | ||
|
|
4d8823b1b3 | ||
|
|
baf56793b6 | ||
|
|
b8674dc363 | ||
|
|
ee4f96656b | ||
|
|
ebc7bfb4f6 |
+57
-124
@@ -1,162 +1,95 @@
|
|||||||
name: Build WordPress Plugin for Gitea
|
name: Build WordPress Plugin (XML-driven)
|
||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
tags:
|
branches:
|
||||||
- 'v*' # Trigger on version tags like v1.0.0
|
- main
|
||||||
# workflow_dispatch: # Uncomment to enable manual trigger
|
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build-release:
|
build-release:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout code
|
- name: Checkout
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
# ------------------------------------------------
|
- name: Install XML tools and zip
|
||||||
# 1. OPTIONAL – Setup PHP & Composer
|
|
||||||
# ------------------------------------------------
|
|
||||||
- name: Setup PHP
|
|
||||||
uses: shivammathur/setup-php@v2
|
|
||||||
with:
|
|
||||||
php-version: '7.4'
|
|
||||||
tools: composer
|
|
||||||
# If your plugin does NOT use Composer, remove this step.
|
|
||||||
|
|
||||||
# ------------------------------------------------
|
|
||||||
# 2. OPTIONAL – Setup Node & NPM
|
|
||||||
# ------------------------------------------------
|
|
||||||
- name: Setup Node.js
|
|
||||||
uses: actions/setup-node@v4
|
|
||||||
with:
|
|
||||||
node-version: '20'
|
|
||||||
cache: 'npm'
|
|
||||||
# If your plugin does NOT use NPM, remove this step.
|
|
||||||
|
|
||||||
# ------------------------------------------------
|
|
||||||
# 3. OPTIONAL – Install dependencies & build assets
|
|
||||||
# ------------------------------------------------
|
|
||||||
- name: Install Composer dependencies (production only)
|
|
||||||
run: |
|
run: |
|
||||||
if [ -f "composer.json" ]; then
|
sudo apt-get update
|
||||||
composer install --no-dev --prefer-dist --optimize-autoloader
|
sudo apt-get install -y libxml2-utils zip
|
||||||
fi
|
|
||||||
|
|
||||||
- name: Install NPM dependencies & build
|
# ------------------------------------------------------------
|
||||||
run: |
|
# 1. Extract metadata from plugin.xml
|
||||||
if [ -f "package.json" ]; then
|
# ------------------------------------------------------------
|
||||||
npm ci
|
- name: Extract metadata from plugin.xml
|
||||||
fi
|
|
||||||
if [ -f "package.json" ] && grep -q '"build"' package.json; then
|
|
||||||
npm run build
|
|
||||||
fi
|
|
||||||
|
|
||||||
# ------------------------------------------------
|
|
||||||
# 4. Extract plugin metadata from main file
|
|
||||||
# ------------------------------------------------
|
|
||||||
- name: Get plugin version and slug
|
|
||||||
id: meta
|
id: meta
|
||||||
run: |
|
run: |
|
||||||
# Find the main plugin file (with "Plugin Name:" header)
|
if [ ! -f plugin.xml ]; then
|
||||||
MAIN_FILE=$(grep -l "Plugin Name:" *.php | head -n 1)
|
echo "❌ plugin.xml not found!" >&2
|
||||||
if [ -z "$MAIN_FILE" ]; then
|
|
||||||
echo "❌ No main plugin file (with 'Plugin Name:') found!" >&2
|
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Extract version (strip trailing carriage returns)
|
NAME=$(xmllint --xpath "string(//name)" plugin.xml)
|
||||||
VERSION=$(grep "^Version:" "$MAIN_FILE" | awk -F' ' '{print $NF}' | tr -d '\r')
|
VERSION=v$(xmllint --xpath "string(//version)" plugin.xml)
|
||||||
if [ -z "$VERSION" ]; then
|
|
||||||
echo "❌ Version header not found in $MAIN_FILE" >&2
|
if [ -z "$NAME" ] || [ -z "$VERSION" ]; then
|
||||||
|
echo "❌ Could not extract <name> or <version> from plugin.xml" >&2
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Use repository name as slug, or override with a custom variable
|
# Sanitize the name to a safe slug (lowercase, replace non-alnum with '-')
|
||||||
SLUG="${GITHUB_REPOSITORY##*/}"
|
SLUG=$(echo "$NAME" | tr '[:upper:]' '[:lower:]' | sed -E 's/[^a-z0-9]+/-/g; s/^-+//; s/-+$//')
|
||||||
|
|
||||||
echo "PLUGIN_SLUG=$SLUG" >> $GITHUB_ENV
|
echo "PLUGIN_NAME=$NAME" >> $GITHUB_ENV
|
||||||
echo "PLUGIN_VERSION=$VERSION" >> $GITHUB_ENV
|
echo "SLUG=$SLUG" >> $GITHUB_ENV
|
||||||
|
echo "VERSION=$VERSION" >> $GITHUB_ENV
|
||||||
echo "FILENAME=${SLUG}-${VERSION}.zip" >> $GITHUB_ENV
|
echo "FILENAME=${SLUG}-${VERSION}.zip" >> $GITHUB_ENV
|
||||||
echo "MAIN_FILE=$MAIN_FILE" >> $GITHUB_ENV
|
|
||||||
echo "✅ Plugin: $SLUG, Version: $VERSION"
|
|
||||||
|
|
||||||
# ------------------------------------------------
|
echo "✅ Plugin: $NAME, Slug: $SLUG, Version: $VERSION"
|
||||||
# 5. Prepare package (exclude dev files)
|
|
||||||
# ------------------------------------------------
|
# ------------------------------------------------------------
|
||||||
- name: Prepare package directory
|
# 2. Prepare package (copy everything EXCEPT plugin.xml, .git, .github)
|
||||||
|
# ------------------------------------------------------------
|
||||||
|
- name: Prepare package
|
||||||
run: |
|
run: |
|
||||||
mkdir -p /tmp/build/${{ env.PLUGIN_SLUG }}
|
mkdir -p build/"$SLUG"
|
||||||
|
# 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"/ \;
|
||||||
|
|
||||||
# Rsync all files, excluding common dev/dependency folders
|
# ------------------------------------------------------------
|
||||||
# If you have a .distignore file, use: --exclude-from='.distignore'
|
# 3. Build the zip
|
||||||
rsync -av \
|
# ------------------------------------------------------------
|
||||||
--exclude='.git' \
|
- name: Build plugin zip
|
||||||
--exclude='.github' \
|
|
||||||
--exclude='.distignore' \
|
|
||||||
--exclude='.gitignore' \
|
|
||||||
--exclude='node_modules' \
|
|
||||||
--exclude='vendor' \ # we installed --no-dev, but safe to exclude anyway
|
|
||||||
--exclude='tests' \
|
|
||||||
--exclude='.env*' \
|
|
||||||
--exclude='*.log' \
|
|
||||||
--exclude='*.map' \
|
|
||||||
--exclude='package-lock.json' \
|
|
||||||
--exclude='composer.lock' \
|
|
||||||
--exclude='package.json' \ # Remove if you want to keep it
|
|
||||||
--exclude='composer.json' \ # Remove if you want to keep it
|
|
||||||
--exclude='webpack.config.js' \
|
|
||||||
--exclude='gulpfile.js' \
|
|
||||||
--exclude='Gruntfile.js' \
|
|
||||||
--exclude='phpunit.xml' \
|
|
||||||
--exclude='.wordpress-org' \
|
|
||||||
./ /tmp/build/${{ env.PLUGIN_SLUG }}/ 2>/dev/null || true
|
|
||||||
|
|
||||||
# Adjust excludes above if your plugin needs any of these files in production.
|
|
||||||
|
|
||||||
# ------------------------------------------------
|
|
||||||
# 6. Create ZIP archive
|
|
||||||
# ------------------------------------------------
|
|
||||||
- name: Create plugin zip
|
|
||||||
run: |
|
run: |
|
||||||
cd /tmp/build
|
cd build
|
||||||
zip -r "$GITHUB_WORKSPACE/${{ env.FILENAME }}" ${{ env.PLUGIN_SLUG }}/
|
zip -r "../$FILENAME" "$SLUG"
|
||||||
cd $GITHUB_WORKSPACE
|
cd ..
|
||||||
echo "✅ Created: $FILENAME"
|
|
||||||
|
|
||||||
# ------------------------------------------------
|
# ------------------------------------------------------------
|
||||||
# 7. Install and configure tea CLI
|
# 4. Install tea CLI
|
||||||
# ------------------------------------------------
|
# ------------------------------------------------------------
|
||||||
- name: Install tea CLI (pinned version)
|
- name: Install tea CLI
|
||||||
run: |
|
run: |
|
||||||
curl -L https://dl.gitea.io/tea/0.11.0/tea-0.11.0-linux-amd64 -o tea
|
curl -L https://dl.gitea.io/tea/main/tea-main-linux-amd64 -o tea
|
||||||
chmod +x tea
|
chmod +x tea
|
||||||
sudo mv tea /usr/local/bin/
|
sudo mv tea /usr/local/bin/
|
||||||
|
|
||||||
|
# ------------------------------------------------------------
|
||||||
|
# 5. Configure tea
|
||||||
|
# ------------------------------------------------------------
|
||||||
- name: Configure tea
|
- name: Configure tea
|
||||||
run: |
|
run: |
|
||||||
tea login add \
|
tea login add \
|
||||||
--name gitea \
|
--name gitea \
|
||||||
--url "${{ vars.GITEA_SERVER_URL }}" \
|
--url "${{ vars.SERVER_URL }}" \
|
||||||
--token "${{ secrets.GITEA_TOKEN }}"
|
--token "${{ secrets.OC3_EXTENSION_RELEASE_TOKEN }}"
|
||||||
|
|
||||||
# ------------------------------------------------
|
# ------------------------------------------------------------
|
||||||
# 8. Create or update Gitea release
|
# 6. Create (or force‑update) release
|
||||||
# ------------------------------------------------
|
# ------------------------------------------------------------
|
||||||
- name: Create Gitea release
|
- name: Create release
|
||||||
run: |
|
run: |
|
||||||
TAG="v${{ env.PLUGIN_VERSION }}"
|
tea release create "$VERSION" \
|
||||||
REPO="${{ vars.GITEA_REPO }}"
|
--title "${PLUGIN_NAME}_${VERSION}" \
|
||||||
|
--asset "${FILENAME}" \
|
||||||
# If a release with this tag already exists, delete it (optional)
|
--force
|
||||||
if tea release list --repo "$REPO" | grep -q "^$TAG "; then
|
|
||||||
echo "Release $TAG already exists – deleting it."
|
|
||||||
tea release delete "$TAG" --repo "$REPO"
|
|
||||||
fi
|
|
||||||
|
|
||||||
tea release create "$TAG" \
|
|
||||||
--title "${{ env.PLUGIN_SLUG }} v${{ env.PLUGIN_VERSION }}" \
|
|
||||||
--asset "${{ env.FILENAME }}" \
|
|
||||||
--repo "$REPO"
|
|
||||||
|
|
||||||
echo "✅ Release $TAG created with asset ${{ env.FILENAME }}"
|
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
<plugin>
|
||||||
|
<name>Advanced SEO Meta + AI FAQ Schema</name>
|
||||||
|
<version>3.0.0</version>
|
||||||
|
</plugin>
|
||||||
Reference in New Issue
Block a user