Files
advanced-seo-keywords/.gitea/workflows/release.yml
T
Mohamed Youssef 412844bb1f
Build WordPress Plugin (XML-driven) / build-release (push) Failing after 35s
update
2026-08-02 10:15:50 +03:00

96 lines
3.3 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 (XML-driven)
on:
push:
branches:
- main
jobs:
build-release:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install XML tools and zip
run: |
sudo apt-get update
sudo apt-get install -y libxml2-utils zip
# ------------------------------------------------------------
# 1. Extract metadata from plugin.xml
# ------------------------------------------------------------
- name: Extract metadata from plugin.xml
id: meta
run: |
if [ ! -f plugin.xml ]; then
echo "❌ plugin.xml not found!" >&2
exit 1
fi
NAME=$(xmllint --xpath "string(//name)" plugin.xml)
VERSION=v$(xmllint --xpath "string(//version)" plugin.xml)
if [ -z "$NAME" ] || [ -z "$VERSION" ]; then
echo "❌ Could not extract <name> or <version> from plugin.xml" >&2
exit 1
fi
# Sanitize the name to a safe slug (lowercase, replace non-alnum with '-')
SLUG=$(echo "$NAME" | tr '[:upper:]' '[:lower:]' | sed -E 's/[^a-z0-9]+/-/g; s/^-+//; s/-+$//')
echo "PLUGIN_NAME=$NAME" >> $GITHUB_ENV
echo "SLUG=$SLUG" >> $GITHUB_ENV
echo "VERSION=$VERSION" >> $GITHUB_ENV
echo "FILENAME=${SLUG}-${VERSION}.zip" >> $GITHUB_ENV
echo "✅ Plugin: $NAME, Slug: $SLUG, Version: $VERSION"
# ------------------------------------------------------------
# 2. Prepare package (copy everything EXCEPT plugin.xml, .git, .github)
# ------------------------------------------------------------
- name: Prepare package
run: |
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"/ \;
# ------------------------------------------------------------
# 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
# ------------------------------------------------------------
- name: Configure tea
run: |
tea login add \
--name gitea \
--url "${{ vars.SERVER_URL }}" \
--token "${{ secrets.OC3_EXTENSION_RELEASE_TOKEN }}"
# ------------------------------------------------------------
# 6. Create (or forceupdate) release
# ------------------------------------------------------------
- name: Create release
run: |
tea release create "$VERSION" \
--title "${PLUGIN_NAME}_${VERSION}" \
--asset "${FILENAME}" \
--repo "${{ vars.GITEA_REPO }}" \
--force