From 6aa4501c2784e96b64a481cf97f7c4c491b33b54 Mon Sep 17 00:00:00 2001 From: bionickatana Date: Mon, 22 Jun 2026 11:37:39 -0600 Subject: [PATCH] Godot auto build --- .gitea/workflows/build.yaml | 90 ++++++++++++++++++++----------------- 1 file changed, 50 insertions(+), 40 deletions(-) diff --git a/.gitea/workflows/build.yaml b/.gitea/workflows/build.yaml index cb0692b..0383416 100644 --- a/.gitea/workflows/build.yaml +++ b/.gitea/workflows/build.yaml @@ -9,8 +9,9 @@ jobs: - name: Check out repository code uses: actions/checkout@v4 - - - name: Auto-Detect Godot Version and Setup Engine (With Caching) + # Step 1: Read project.godot ahead of time to get the version for our cache key + - name: Detect Godot Version + id: detect-version run: | echo "🔍 Parsing project.godot to identify the target engine version..." VERSION_SHORT=$(grep "config/features" project.godot | sed -E 's/^[^\"]*\"([^\"]+)\".*/\1/' | xargs) @@ -19,55 +20,64 @@ jobs: VERSION_SHORT="4.7" fi - VERSION_URL="${VERSION_SHORT}-stable" - VERSION_FILE="${VERSION_SHORT}.stable" - - # Paths inside our persistent volume - CACHE_DIR="/root/.godot-si-cache/${VERSION_FILE}" - + echo "VERSION_SHORT=${VERSION_SHORT}" >> $GITHUB_OUTPUT + echo "VERSION_URL=${VERSION_SHORT}-stable" >> $GITHUB_OUTPUT + echo "VERSION_FILE=${VERSION_SHORT}.stable" >> $GITHUB_OUTPUT echo "🎯 Detected Target Version: $VERSION_SHORT" - echo "----------------------------------------------" - # Check if this specific version is already cached - if [ -f "${CACHE_DIR}/godot" ] && [ -f "${CACHE_DIR}/linux_release.x86_64" ]; then - echo "🚀 Cache Hit! Found Godot ${VERSION_SHORT} locally. Copying files..." - cp "${CACHE_DIR}/godot" ./godot - mkdir -p ~/.local/share/godot/export_templates/${VERSION_FILE} - cp "${CACHE_DIR}/linux_release.x86_64" ~/.local/share/godot/export_templates/${VERSION_FILE}/linux_release.x86_64 - else - echo "📥 Cache Miss. Downloading Godot Engine ($VERSION_URL)..." - curl -L "https://github.com/godotengine/godot/releases/download/${VERSION_URL}/Godot_v${VERSION_URL}_linux.x86_64.zip" -o godot.zip - unzip godot.zip - mv "Godot_v${VERSION_URL}_linux.x86_64" godot - chmod +x godot + # Step 2: Look for the cached Godot folder inside the Gitea Actions cache + - name: Cache Godot Engine and Templates + id: godot-cache + uses: actions/cache@v4 + with: + path: .godot-cache-storage + key: godot-${{ steps.detect-version.outputs.VERSION_FILE }}-linux-v1 - echo "📥 Downloading Export Templates ($VERSION_URL)..." - curl -L "https://github.com/godotengine/godot/releases/download/${VERSION_URL}/Godot_v${VERSION_URL}_export_templates.tpz" -o templates.zip - unzip templates.zip - - echo "🔧 Mapping Template Directories..." - mkdir -p ~/.local/share/godot/export_templates/${VERSION_FILE} - mv templates/linux_release.x86_64 ~/.local/share/godot/export_templates/${VERSION_FILE}/linux_release.x86_64 - - echo "💾 Saving files to persistent host cache for next time..." - mkdir -p "${CACHE_DIR}" - cp ./godot "${CACHE_DIR}/godot" - cp ~/.local/share/godot/export_templates/${VERSION_FILE}/linux_release.x86_64 "${CACHE_DIR}/linux_release.x86_64" - fi + # Step 3: Run only on a Cache Miss to download the engine files + - name: Download Godot Engine and Templates (On Cache Miss) + if: steps.godot-cache.outputs.cache-hit != 'true' + run: | + VERSION_URL="${{ steps.detect-version.outputs.VERSION_URL }}" + mkdir -p .godot-cache-storage + + echo "📥 Cache Miss. Downloading Godot Engine ($VERSION_URL)..." + curl -L "https://github.com/godotengine/godot/releases/download/${VERSION_URL}/Godot_v${VERSION_URL}_linux.x86_64.zip" -o godot.zip + unzip godot.zip + mv "Godot_v${VERSION_URL}_linux.x86_64" .godot-cache-storage/godot + chmod +x .godot-cache-storage/godot + echo "📥 Downloading Export Templates ($VERSION_URL)..." + curl -L "https://github.com/godotengine/godot/releases/download/${VERSION_URL}/Godot_v${VERSION_URL}_export_templates.tpz" -o templates.zip + unzip templates.zip + mv templates/linux_release.x86_64 .godot-cache-storage/linux_release.x86_64 + + # Clean up download archives + rm godot.zip templates.zip + rm -rf templates/ + + # Step 4: Always map the binaries from our local workspace folder into their final execution paths + - name: Map Engine and Templates + run: | + VERSION_FILE="${{ steps.detect-version.outputs.VERSION_FILE }}" + + # Copy engine executable out to project root + cp .godot-cache-storage/godot ./godot + + # Inject template into user profile folder where Godot looks for them during exports + mkdir -p ~/.local/share/godot/export_templates/${VERSION_FILE} + cp .godot-cache-storage/linux_release.x86_64 ~/.local/share/godot/export_templates/${VERSION_FILE}/linux_release.x86_64 + echo "🚀 Environment ready for export!" + + # Step 5: Export the binary - name: Export Linux Binary run: | - mkdir -p "${{ gitea.workspace }}/build/linux" mkdir -p build/linux ./godot --headless --export-release "Linux" build/linux/godot_number_factory.x86_64 - - name: debug - run: | - ls -la "${{ gitea.workspace }}/build/linux" - ls -la build/linux - + # Step 6: Upload artifacts using action version safety features compatible with Gitea - name: Upload Linux Build Artifact uses: actions/upload-artifact@v4 with: name: linux-build path: build/linux/ + if-no-files-found: error