Files
advanced-seo-keywords/.gitea/workflows/release.yml
T
Mohamed Youssef ee4f96656b
Build WordPress Plugin for Gitea / build-release (push) Failing after 8s
update
2026-08-02 09:43:21 +03:00

153 lines
5.0 KiB
YAML
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
name: Build WordPress Plugin for Gitea
on:
push:
branches:
- main # Triggers on every push to main
jobs:
build-release:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
# --------------------------------
# OPTIONAL: Setup PHP & Composer
# --------------------------------
# - name: Setup PHP
# uses: shivammathur/setup-php@v2
# with:
# php-version: '7.4'
# tools: composer
# Remove if your plugin does not use Composer.
# --------------------------------
# OPTIONAL: Setup Node & NPM
# --------------------------------
# - name: Setup Node.js
# uses: actions/setup-node@v4
# with:
# node-version: '20'
# cache: 'npm'
# Remove if your plugin does not use NPM.
# --------------------------------
# OPTIONAL: Install dependencies & build assets
# --------------------------------
# - name: Install Composer dependencies (production only)
# run: |
# if [ -f "composer.json" ]; then
# composer install --no-dev --prefer-dist --optimize-autoloader
# fi
# - name: Install NPM dependencies & build
# run: |
# if [ -f "package.json" ]; then
# npm ci
# fi
# if [ -f "package.json" ] && grep -q '"build"' package.json; then
# npm run build
# fi
# --------------------------------
# Extract plugin metadata
# --------------------------------
- name: Get plugin version and slug
id: meta
run: |
MAIN_FILE=$(grep -l "Plugin Name:" *.php | head -n 1)
if [ -z "$MAIN_FILE" ]; then
echo "❌ No main plugin file (with 'Plugin Name:') found!" >&2
exit 1
fi
VERSION=$(grep "^Version:" "$MAIN_FILE" | awk -F' ' '{print $NF}' | tr -d '\r')
if [ -z "$VERSION" ]; then
echo "❌ Version header not found in $MAIN_FILE" >&2
exit 1
fi
# Use repository name as the plugin slug
SLUG="${GITHUB_REPOSITORY##*/}"
echo "PLUGIN_SLUG=$SLUG" >> $GITHUB_ENV
echo "PLUGIN_VERSION=$VERSION" >> $GITHUB_ENV
echo "FILENAME=${SLUG}-${VERSION}.zip" >> $GITHUB_ENV
echo "✅ Plugin: $SLUG, Version: $VERSION"
# --------------------------------
# Prepare package (exclude dev files)
# --------------------------------
- name: Prepare package directory
run: |
mkdir -p /tmp/build/${{ env.PLUGIN_SLUG }}
# If you have a .distignore file, use: --exclude-from='.distignore'
rsync -av \
--exclude='.git' \
--exclude='.github' \
--exclude='.distignore' \
--exclude='.gitignore' \
--exclude='node_modules' \
--exclude='vendor' \
--exclude='tests' \
--exclude='.env*' \
--exclude='*.log' \
--exclude='*.map' \
--exclude='package-lock.json' \
--exclude='composer.lock' \
--exclude='package.json' \
--exclude='composer.json' \
--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 if your plugin needs any of these files in production.
# --------------------------------
# Create ZIP archive
# --------------------------------
- name: Create plugin zip
run: |
cd /tmp/build
zip -r "$GITHUB_WORKSPACE/${{ env.FILENAME }}" ${{ env.PLUGIN_SLUG }}/
cd $GITHUB_WORKSPACE
echo "✅ Created: $FILENAME"
# --------------------------------
# Install & configure tea CLI
# --------------------------------
- name: Install tea CLI (pinned version)
run: |
curl -L https://dl.gitea.io/tea/0.11.0/tea-0.11.0-linux-amd64 -o tea
chmod +x tea
sudo mv tea /usr/local/bin/
- name: Configure tea
run: |
tea login add \
--name gitea \
--url "${{ vars.GITEA_SERVER_URL }}" \
--token "${{ secrets.GITEA_TOKEN }}"
# --------------------------------
# Create or forceupdate Gitea release
# --------------------------------
- name: Create/update Gitea release
run: |
TAG="v${{ env.PLUGIN_VERSION }}"
REPO="${{ vars.GITEA_REPO }}"
# --force will overwrite an existing release with the same tag
tea release create "$TAG" \
--title "${{ env.PLUGIN_SLUG }} v${{ env.PLUGIN_VERSION }}" \
--asset "${{ env.FILENAME }}" \
--repo "$REPO" \
--force
echo "✅ Release $TAG created/updated with asset ${{ env.FILENAME }}"