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 or 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 force‑update) release # ------------------------------------------------------------ - name: Create release run: | tea release create "$VERSION" \ --title "${PLUGIN_NAME}_${VERSION}" \ --asset "${FILENAME}" \ --repo "${{ vars.GITEA_REPO }}" \ --force