146 lines
6.2 KiB
YAML
146 lines
6.2 KiB
YAML
name: Build Godot Project (Linux & Windows)
|
|
on: [push]
|
|
|
|
jobs:
|
|
build-linux:
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
- name: Check out repository code
|
|
uses: actions/checkout@v4
|
|
|
|
# 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)
|
|
|
|
if [ -z "$VERSION_SHORT" ]; then
|
|
VERSION_SHORT="4.7"
|
|
fi
|
|
|
|
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"
|
|
|
|
# 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
|
|
|
|
# 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 build/linux
|
|
./godot --headless --export-release "Linux" build/linux/godot_number_factory.x86_64
|
|
|
|
# Step 6: Upload artifacts using Gitea-compatible v3 action
|
|
- name: Upload Linux Build Artifact
|
|
uses: actions/upload-artifact@v3
|
|
with:
|
|
name: linux-build
|
|
path: build/linux/
|
|
|
|
build-windows:
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
- name: Check out repository code
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Detect Godot Version
|
|
id: detect-version
|
|
run: |
|
|
VERSION_SHORT=$(grep "config/features" project.godot | sed -E 's/^[^\"]*\"([^\"]+)\".*/\1/' | xargs)
|
|
if [ -z "$VERSION_SHORT" ]; then VERSION_SHORT="4.7"; fi
|
|
echo "VERSION_SHORT=${VERSION_SHORT}" >> $GITHUB_OUTPUT
|
|
echo "VERSION_URL=${VERSION_SHORT}-stable" >> $GITHUB_OUTPUT
|
|
echo "VERSION_FILE=${VERSION_SHORT}.stable" >> $GITHUB_OUTPUT
|
|
|
|
- name: Cache Godot Engine and Windows Templates
|
|
id: godot-cache-windows
|
|
uses: actions/cache@v4
|
|
with:
|
|
path: .godot-cache-windows-storage
|
|
key: godot-${{ steps.detect-version.outputs.VERSION_FILE }}-windows-v1
|
|
|
|
- name: Download Godot Engine and Windows Templates (On Cache Miss)
|
|
if: steps.godot-cache-windows.outputs.cache-hit != 'true'
|
|
run: |
|
|
VERSION_URL="${{ steps.detect-version.outputs.VERSION_URL }}"
|
|
mkdir -p .godot-cache-windows-storage
|
|
|
|
# We still download the Linux engine binary because our runner environment is Linux
|
|
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-windows-storage/godot
|
|
chmod +x .godot-cache-windows-storage/godot
|
|
|
|
# Download the export templates, pulling the windows binary out of the compressed file
|
|
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/windows_release_x86_64.exe .godot-cache-windows-storage/windows_release_x86_64.exe
|
|
|
|
rm godot.zip templates.zip
|
|
rm -rf templates/
|
|
|
|
- name: Map Engine and Windows Templates
|
|
run: |
|
|
VERSION_FILE="${{ steps.detect-version.outputs.VERSION_FILE }}"
|
|
cp .godot-cache-windows-storage/godot ./godot
|
|
|
|
mkdir -p ~/.local/share/godot/export_templates/${VERSION_FILE}
|
|
cp .godot-cache-windows-storage/windows_release_x86_64.exe ~/.local/share/godot/export_templates/${VERSION_FILE}/windows_release_x86_64.exe
|
|
|
|
- name: Export Windows Binary
|
|
run: |
|
|
mkdir -p build/windows
|
|
# Ensure "Windows" matches the exact name of your export preset in Godot
|
|
./godot --headless --export-release "Windows" build/windows/godot_number_factory.exe
|
|
|
|
- name: Upload Windows Build Artifact
|
|
uses: actions/upload-artifact@v3
|
|
with:
|
|
name: windows-build
|
|
path: build/windows/
|