|
| 1 | +--- |
| 2 | +name: Check Editor Releases |
| 3 | + |
| 4 | +on: |
| 5 | + schedule: |
| 6 | + - cron: "0 8 * * *" # Daily at 8:00 UTC |
| 7 | + workflow_dispatch: |
| 8 | + |
| 9 | +permissions: |
| 10 | + contents: write |
| 11 | + actions: write |
| 12 | + |
| 13 | +jobs: |
| 14 | + check_and_build: |
| 15 | + runs-on: ubuntu-latest |
| 16 | + steps: |
| 17 | + - uses: actions/checkout@v4 |
| 18 | + |
| 19 | + - name: Get latest exelearning release |
| 20 | + id: check |
| 21 | + env: |
| 22 | + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 23 | + run: | |
| 24 | + # Fetch latest release from exelearning/exelearning |
| 25 | + LATEST=$(gh api repos/exelearning/exelearning/releases/latest --jq '.tag_name' 2>/dev/null || echo "") |
| 26 | + if [ -z "$LATEST" ]; then |
| 27 | + echo "No release found" |
| 28 | + echo "found=false" >> $GITHUB_OUTPUT |
| 29 | + exit 0 |
| 30 | + fi |
| 31 | + echo "Latest editor release: $LATEST" |
| 32 | + echo "tag=$LATEST" >> $GITHUB_OUTPUT |
| 33 | +
|
| 34 | + # Check if we already built this version |
| 35 | + MARKER_FILE=".editor-version" |
| 36 | + CURRENT="" |
| 37 | + if [ -f "$MARKER_FILE" ]; then |
| 38 | + CURRENT=$(cat "$MARKER_FILE") |
| 39 | + fi |
| 40 | + echo "Current built version: $CURRENT" |
| 41 | +
|
| 42 | + if [ "$LATEST" = "$CURRENT" ]; then |
| 43 | + echo "Already up to date" |
| 44 | + echo "found=false" >> $GITHUB_OUTPUT |
| 45 | + else |
| 46 | + echo "New version available" |
| 47 | + echo "found=true" >> $GITHUB_OUTPUT |
| 48 | + fi |
| 49 | +
|
| 50 | + - name: Setup Bun |
| 51 | + if: steps.check.outputs.found == 'true' |
| 52 | + uses: oven-sh/setup-bun@v2 |
| 53 | + |
| 54 | + - name: Build static editor |
| 55 | + if: steps.check.outputs.found == 'true' |
| 56 | + env: |
| 57 | + EXELEARNING_EDITOR_REPO_URL: https://github.com/exelearning/exelearning.git |
| 58 | + EXELEARNING_EDITOR_REF: ${{ steps.check.outputs.tag }} |
| 59 | + EXELEARNING_EDITOR_REF_TYPE: tag |
| 60 | + run: make build-editor |
| 61 | + |
| 62 | + - name: Compute version |
| 63 | + if: steps.check.outputs.found == 'true' |
| 64 | + id: version |
| 65 | + run: | |
| 66 | + TAG="${{ steps.check.outputs.tag }}" |
| 67 | + VERSION="${TAG#v}" |
| 68 | + echo "version=$VERSION" >> $GITHUB_OUTPUT |
| 69 | + echo "tag=$TAG" >> $GITHUB_OUTPUT |
| 70 | +
|
| 71 | + - name: Create package |
| 72 | + if: steps.check.outputs.found == 'true' |
| 73 | + run: make package RELEASE=${{ steps.version.outputs.version }} |
| 74 | + |
| 75 | + - name: Update editor version marker |
| 76 | + if: steps.check.outputs.found == 'true' |
| 77 | + run: | |
| 78 | + echo "${{ steps.check.outputs.tag }}" > .editor-version |
| 79 | + git config user.name "github-actions[bot]" |
| 80 | + git config user.email "github-actions[bot]@users.noreply.github.com" |
| 81 | + git add .editor-version |
| 82 | + git commit -m "Update editor version to ${{ steps.check.outputs.tag }}" |
| 83 | + git push |
| 84 | +
|
| 85 | + - name: Create GitHub Release |
| 86 | + if: steps.check.outputs.found == 'true' |
| 87 | + uses: softprops/action-gh-release@v2 |
| 88 | + with: |
| 89 | + tag_name: ${{ steps.version.outputs.tag }} |
| 90 | + name: "${{ steps.version.outputs.tag }}" |
| 91 | + body: | |
| 92 | + Automated build with eXeLearning editor ${{ steps.version.outputs.tag }}. |
| 93 | + files: mod_exeweb-${{ steps.version.outputs.version }}.zip |
| 94 | + env: |
| 95 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
0 commit comments