Skip to content

Check Editor Releases #35

Check Editor Releases

Check Editor Releases #35

---
name: Check Editor Releases
on:
schedule:
- cron: "0 8 * * *" # Daily at 8:00 UTC
workflow_dispatch:
permissions:
contents: write
actions: write
jobs:
check_and_build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- name: Get latest exelearning release
id: check
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
# Fetch latest release from exelearning/exelearning
LATEST=$(gh api repos/exelearning/exelearning/releases/latest --jq '.tag_name' 2>/dev/null || echo "")
if [ -z "$LATEST" ]; then
echo "No release found"
echo "found=false" >> $GITHUB_OUTPUT
exit 0
fi
echo "Latest editor release: $LATEST"
echo "tag=$LATEST" >> $GITHUB_OUTPUT
# Check if we already built this version
MARKER_FILE=".editor-version"
CURRENT=""
if [ -f "$MARKER_FILE" ]; then
CURRENT=$(cat "$MARKER_FILE")
fi
echo "Current built version: $CURRENT"
if [ "$LATEST" = "$CURRENT" ]; then
echo "Already up to date"
echo "found=false" >> $GITHUB_OUTPUT
else
echo "New version available"
echo "found=true" >> $GITHUB_OUTPUT
fi
- name: Setup Bun
if: steps.check.outputs.found == 'true'
uses: oven-sh/setup-bun@v2
- name: Build static editor
if: steps.check.outputs.found == 'true'
env:
EXELEARNING_EDITOR_REPO_URL: https://github.com/exelearning/exelearning.git
EXELEARNING_EDITOR_REF: ${{ steps.check.outputs.tag }}
EXELEARNING_EDITOR_REF_TYPE: tag
run: make build-editor
- name: Compute version
if: steps.check.outputs.found == 'true'
id: version
run: |
TAG="${{ steps.check.outputs.tag }}"
VERSION="${TAG#v}"
echo "version=$VERSION" >> $GITHUB_OUTPUT
echo "tag=$TAG" >> $GITHUB_OUTPUT
- name: Create package
if: steps.check.outputs.found == 'true'
run: |
make package VERSION=${{ steps.version.outputs.version }}
- name: Update editor version marker
if: steps.check.outputs.found == 'true'
run: |
echo "${{ steps.check.outputs.tag }}" > .editor-version
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add .editor-version
git commit -m "Update editor version to ${{ steps.check.outputs.tag }}"
git push
- name: Build Playground URL for this release
if: steps.check.outputs.found == 'true'
id: playground
run: |
RELEASE_URL="https://github.com/${{ github.repository }}/releases/download/${{ steps.version.outputs.tag }}/exelearning-${{ steps.version.outputs.version }}.zip"
BLUEPRINT=$(jq --arg url "$RELEASE_URL" '.steps[1].pluginData.url = $url' blueprint.json)
ENCODED=$(echo "$BLUEPRINT" | base64 -w 0)
echo "url=https://playground.wordpress.net/#${ENCODED}" >> $GITHUB_OUTPUT
- name: Create GitHub Release
if: steps.check.outputs.found == 'true'
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ steps.version.outputs.tag }}
name: "${{ steps.version.outputs.tag }}"
body: |
Automated build with eXeLearning editor ${{ steps.version.outputs.tag }}.
---
<a href="${{ steps.playground.outputs.url }}"><img src="https://raw.githubusercontent.com/${{ github.repository }}/refs/heads/main/.github/playground-preview-button.svg" alt="Preview in WordPress Playground" width="224"></a>
files: exelearning-${{ steps.version.outputs.version }}.zip
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}