Files
advanced-seo-keywords/.gitea/workflows/release.yml
T
Mohamed Youssef 5b9ad90ed7
Build WordPress Plugin (Simple) / build-release (push) Failing after 24s
update
2026-08-02 09:55:53 +03:00

96 lines
3.4 KiB
YAML

name: Build WordPress Plugin (Simple)
on:
push:
branches:
- main
jobs:
build-release:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install zip
run: sudo apt-get update && sudo apt-get install -y zip
# -----------------------------------------------------------------
# 1. Find the main plugin file and extract slug & version
# -----------------------------------------------------------------
- name: Extract plugin metadata
id: meta
run: |
# Find the file that contains "Plugin Name:"
MAIN_FILE=$(grep -rl "Plugin Name:" *.php | head -n1)
if [ -z "$MAIN_FILE" ]; then
echo "❌ No plugin file with 'Plugin Name:' found!" >&2
exit 1
fi
# Extract version (strip trailing newline)
VERSION=$(grep "^Version:" "$MAIN_FILE" | awk '{print $NF}' | tr -d '\r')
if [ -z "$VERSION" ]; then
echo "❌ Version not found in $MAIN_FILE" >&2
exit 1
fi
# Use repository name as the slug (or override with a custom variable)
SLUG="${GITHUB_REPOSITORY##*/}"
echo "SLUG=$SLUG" >> $GITHUB_ENV
echo "VERSION=$VERSION" >> $GITHUB_ENV
echo "FILENAME=${SLUG}-${VERSION}.zip" >> $GITHUB_ENV
echo "✅ Plugin: $SLUG, Version: $VERSION"
# -----------------------------------------------------------------
# 2. Prepare the package (copy everything except .git and .github)
# -----------------------------------------------------------------
- name: Prepare package
run: |
mkdir -p build/"$SLUG"
# Copy all files, but exclude git and github folders (optional)
rsync -a --exclude='.git' --exclude='.github' ./ build/"$SLUG"/
# If you want to exclude node_modules, vendor, etc., add more --exclude's
# -----------------------------------------------------------------
# 3. Build the zip
# -----------------------------------------------------------------
- name: Build plugin zip
run: |
cd build
zip -r "../$FILENAME" "$SLUG"
cd ..
# -----------------------------------------------------------------
# 4. Install tea CLI
# -----------------------------------------------------------------
- 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/
# -----------------------------------------------------------------
# 5. Configure tea (using your existing variables)
# -----------------------------------------------------------------
- name: Configure tea
run: |
tea login add \
--name gitea \
--url "${{ vars.SERVER_URL }}" \
--token "${{ secrets.OC3_EXTENSION_RELEASE_TOKEN }}"
# -----------------------------------------------------------------
# 6. Create/force-update release
# -----------------------------------------------------------------
- name: Create release
run: |
TAG="v${VERSION}"
tea release create "$TAG" \
--title "${SLUG}_${VERSION}" \
--asset "${FILENAME}" \
--repo "${{ vars.GITEA_REPO }}" \
--force # <-- overwrites if tag exists