436 lines
15 KiB
YAML
436 lines
15 KiB
YAML
name: Build Game
|
|
|
|
# Build pipeline for creating game executables across multiple platforms
|
|
#
|
|
# Features:
|
|
# - Manual trigger with platform selection
|
|
# - Tag-based automatic builds for releases
|
|
# - Multi-platform builds (Windows, Linux, macOS, Android)
|
|
# - Artifact storage for one week
|
|
# - Configurable build options
|
|
|
|
on:
|
|
# Manual trigger with platform selection
|
|
workflow_dispatch:
|
|
inputs:
|
|
platforms:
|
|
description: 'Platforms to build (comma-separated: windows,linux,macos,android)'
|
|
required: true
|
|
default: 'windows,linux'
|
|
type: string
|
|
build_type:
|
|
description: 'Build type'
|
|
required: true
|
|
default: 'release'
|
|
type: choice
|
|
options:
|
|
- release
|
|
- debug
|
|
version_override:
|
|
description: 'Override version (optional)'
|
|
required: false
|
|
type: string
|
|
|
|
# Automatic trigger on git tags (for releases)
|
|
push:
|
|
tags:
|
|
- 'v*' # Version tags (v1.0.0, v2.1.0, etc.)
|
|
- 'release-*' # Release tags
|
|
|
|
env:
|
|
GODOT_VERSION: "4.4.1"
|
|
PROJECT_NAME: "Skelly"
|
|
BUILD_DIR: "builds"
|
|
|
|
jobs:
|
|
# Preparation job - determines build configuration
|
|
prepare:
|
|
name: Prepare Build
|
|
runs-on: ubuntu-latest
|
|
outputs:
|
|
platforms: ${{ steps.config.outputs.platforms }}
|
|
build_type: ${{ steps.config.outputs.build_type }}
|
|
version: ${{ steps.config.outputs.version }}
|
|
artifact_name: ${{ steps.config.outputs.artifact_name }}
|
|
|
|
steps:
|
|
- name: Checkout repository
|
|
uses: actions/checkout@v4
|
|
with:
|
|
fetch-depth: 0
|
|
|
|
- name: Configure build parameters
|
|
id: config
|
|
run: |
|
|
# Determine platforms to build
|
|
if [[ "${{ github.event_name }}" == "workflow_dispatch" ]]; then
|
|
platforms="${{ github.event.inputs.platforms }}"
|
|
build_type="${{ github.event.inputs.build_type }}"
|
|
version_override="${{ github.event.inputs.version_override }}"
|
|
else
|
|
# Tag-triggered build - build all platforms
|
|
platforms="windows,linux,macos,android"
|
|
build_type="release"
|
|
version_override=""
|
|
fi
|
|
|
|
# Determine version
|
|
if [[ -n "$version_override" ]]; then
|
|
version="$version_override"
|
|
elif [[ "${{ github.ref_type }}" == "tag" ]]; then
|
|
version="${{ github.ref_name }}"
|
|
else
|
|
# Generate version from git info
|
|
commit_short=$(git rev-parse --short HEAD)
|
|
branch_name="${{ github.ref_name }}"
|
|
timestamp=$(date +%Y%m%d-%H%M)
|
|
version="${branch_name}-${commit_short}-${timestamp}"
|
|
fi
|
|
|
|
# Create artifact name
|
|
artifact_name="${{ env.PROJECT_NAME }}-${version}-${build_type}"
|
|
|
|
echo "platforms=${platforms}" >> $GITHUB_OUTPUT
|
|
echo "build_type=${build_type}" >> $GITHUB_OUTPUT
|
|
echo "version=${version}" >> $GITHUB_OUTPUT
|
|
echo "artifact_name=${artifact_name}" >> $GITHUB_OUTPUT
|
|
|
|
echo "🔧 Build Configuration:"
|
|
echo " Platforms: ${platforms}"
|
|
echo " Build Type: ${build_type}"
|
|
echo " Version: ${version}"
|
|
echo " Artifact: ${artifact_name}"
|
|
|
|
# Windows build job
|
|
build-windows:
|
|
name: Build Windows
|
|
runs-on: ubuntu-latest
|
|
needs: prepare
|
|
if: contains(needs.prepare.outputs.platforms, 'windows')
|
|
|
|
steps:
|
|
- name: Checkout repository
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Setup Godot
|
|
uses: chickensoft-games/setup-godot@v1
|
|
with:
|
|
version: ${{ env.GODOT_VERSION }}
|
|
use-dotnet: false
|
|
|
|
- name: Install export templates
|
|
run: |
|
|
echo "📦 Installing Godot export templates..."
|
|
mkdir -p ~/.local/share/godot/export_templates/${{ env.GODOT_VERSION }}.stable
|
|
wget -q https://github.com/godotengine/godot/releases/download/${{ env.GODOT_VERSION }}-stable/Godot_v${{ env.GODOT_VERSION }}-stable_export_templates.tpz
|
|
unzip -q Godot_v${{ env.GODOT_VERSION }}-stable_export_templates.tpz
|
|
mv templates/* ~/.local/share/godot/export_templates/${{ env.GODOT_VERSION }}.stable/
|
|
echo "✅ Export templates installed successfully"
|
|
ls -la ~/.local/share/godot/export_templates/${{ env.GODOT_VERSION }}.stable/
|
|
|
|
- name: Create build directory
|
|
run: mkdir -p ${{ env.BUILD_DIR }}
|
|
|
|
- name: Import project assets
|
|
run: |
|
|
echo "📦 Importing project assets..."
|
|
godot --headless --verbose --editor --quit || true
|
|
sleep 2
|
|
|
|
- name: Build Windows executable
|
|
run: |
|
|
echo "🏗️ Building Windows executable..."
|
|
godot --headless --verbose --export-${{ needs.prepare.outputs.build_type }} "Windows Desktop" \
|
|
${{ env.BUILD_DIR }}/skelly-windows-${{ needs.prepare.outputs.version }}.exe
|
|
|
|
# Verify build output
|
|
if [[ -f "${{ env.BUILD_DIR }}/skelly-windows-${{ needs.prepare.outputs.version }}.exe" ]]; then
|
|
echo "✅ Windows build successful"
|
|
ls -la ${{ env.BUILD_DIR }}/
|
|
else
|
|
echo "❌ Windows build failed"
|
|
exit 1
|
|
fi
|
|
|
|
- name: Upload Windows build
|
|
uses: actions/upload-artifact@v3
|
|
with:
|
|
name: ${{ needs.prepare.outputs.artifact_name }}-windows
|
|
path: ${{ env.BUILD_DIR }}/skelly-windows-${{ needs.prepare.outputs.version }}.exe
|
|
retention-days: 7
|
|
compression-level: 0
|
|
|
|
# Linux build job
|
|
build-linux:
|
|
name: Build Linux
|
|
runs-on: ubuntu-latest
|
|
needs: prepare
|
|
if: contains(needs.prepare.outputs.platforms, 'linux')
|
|
|
|
steps:
|
|
- name: Checkout repository
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Setup Godot
|
|
uses: chickensoft-games/setup-godot@v1
|
|
with:
|
|
version: ${{ env.GODOT_VERSION }}
|
|
use-dotnet: false
|
|
|
|
- name: Install export templates
|
|
run: |
|
|
echo "📦 Installing Godot export templates..."
|
|
mkdir -p ~/.local/share/godot/export_templates/${{ env.GODOT_VERSION }}.stable
|
|
wget -q https://github.com/godotengine/godot/releases/download/${{ env.GODOT_VERSION }}-stable/Godot_v${{ env.GODOT_VERSION }}-stable_export_templates.tpz
|
|
unzip -q Godot_v${{ env.GODOT_VERSION }}-stable_export_templates.tpz
|
|
mv templates/* ~/.local/share/godot/export_templates/${{ env.GODOT_VERSION }}.stable/
|
|
echo "✅ Export templates installed successfully"
|
|
ls -la ~/.local/share/godot/export_templates/${{ env.GODOT_VERSION }}.stable/
|
|
|
|
- name: Create build directory
|
|
run: mkdir -p ${{ env.BUILD_DIR }}
|
|
|
|
- name: Import project assets
|
|
run: |
|
|
echo "📦 Importing project assets..."
|
|
godot --headless --verbose --editor --quit || true
|
|
sleep 2
|
|
|
|
- name: Build Linux executable
|
|
run: |
|
|
echo "🏗️ Building Linux executable..."
|
|
godot --headless --verbose --export-${{ needs.prepare.outputs.build_type }} "Linux" \
|
|
${{ env.BUILD_DIR }}/skelly-linux-${{ needs.prepare.outputs.version }}.x86_64
|
|
|
|
# Make executable
|
|
chmod +x ${{ env.BUILD_DIR }}/skelly-linux-${{ needs.prepare.outputs.version }}.x86_64
|
|
|
|
# Verify build output
|
|
if [[ -f "${{ env.BUILD_DIR }}/skelly-linux-${{ needs.prepare.outputs.version }}.x86_64" ]]; then
|
|
echo "✅ Linux build successful"
|
|
ls -la ${{ env.BUILD_DIR }}/
|
|
else
|
|
echo "❌ Linux build failed"
|
|
exit 1
|
|
fi
|
|
|
|
- name: Upload Linux build
|
|
uses: actions/upload-artifact@v3
|
|
with:
|
|
name: ${{ needs.prepare.outputs.artifact_name }}-linux
|
|
path: ${{ env.BUILD_DIR }}/skelly-linux-${{ needs.prepare.outputs.version }}.x86_64
|
|
retention-days: 7
|
|
compression-level: 0
|
|
|
|
# macOS build job
|
|
build-macos:
|
|
name: Build macOS
|
|
runs-on: ubuntu-latest
|
|
needs: prepare
|
|
if: contains(needs.prepare.outputs.platforms, 'macos')
|
|
|
|
steps:
|
|
- name: Checkout repository
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Setup Godot
|
|
uses: chickensoft-games/setup-godot@v1
|
|
with:
|
|
version: ${{ env.GODOT_VERSION }}
|
|
use-dotnet: false
|
|
|
|
- name: Install export templates
|
|
run: |
|
|
echo "📦 Installing Godot export templates..."
|
|
mkdir -p ~/.local/share/godot/export_templates/${{ env.GODOT_VERSION }}.stable
|
|
wget -q https://github.com/godotengine/godot/releases/download/${{ env.GODOT_VERSION }}-stable/Godot_v${{ env.GODOT_VERSION }}-stable_export_templates.tpz
|
|
unzip -q Godot_v${{ env.GODOT_VERSION }}-stable_export_templates.tpz
|
|
mv templates/* ~/.local/share/godot/export_templates/${{ env.GODOT_VERSION }}.stable/
|
|
echo "✅ Export templates installed successfully"
|
|
ls -la ~/.local/share/godot/export_templates/${{ env.GODOT_VERSION }}.stable/
|
|
|
|
- name: Create build directory
|
|
run: mkdir -p ${{ env.BUILD_DIR }}
|
|
|
|
- name: Import project assets
|
|
run: |
|
|
echo "📦 Importing project assets..."
|
|
godot --headless --verbose --editor --quit || true
|
|
sleep 2
|
|
|
|
- name: Build macOS application
|
|
run: |
|
|
echo "🏗️ Building macOS application..."
|
|
godot --headless --verbose --export-${{ needs.prepare.outputs.build_type }} "macOS" \
|
|
${{ env.BUILD_DIR }}/skelly-macos-${{ needs.prepare.outputs.version }}.zip
|
|
|
|
# Verify build output
|
|
if [[ -f "${{ env.BUILD_DIR }}/skelly-macos-${{ needs.prepare.outputs.version }}.zip" ]]; then
|
|
echo "✅ macOS build successful"
|
|
ls -la ${{ env.BUILD_DIR }}/
|
|
else
|
|
echo "❌ macOS build failed"
|
|
exit 1
|
|
fi
|
|
|
|
- name: Upload macOS build
|
|
uses: actions/upload-artifact@v3
|
|
with:
|
|
name: ${{ needs.prepare.outputs.artifact_name }}-macos
|
|
path: ${{ env.BUILD_DIR }}/skelly-macos-${{ needs.prepare.outputs.version }}.zip
|
|
retention-days: 7
|
|
compression-level: 0
|
|
|
|
# Android build job
|
|
build-android:
|
|
name: Build Android
|
|
runs-on: ubuntu-latest
|
|
needs: prepare
|
|
if: contains(needs.prepare.outputs.platforms, 'android')
|
|
|
|
steps:
|
|
- name: Checkout repository
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Setup Java
|
|
uses: actions/setup-java@v4
|
|
with:
|
|
distribution: 'temurin'
|
|
java-version: '17'
|
|
|
|
- name: Setup Android SDK
|
|
uses: android-actions/setup-android@v3
|
|
with:
|
|
api-level: 33
|
|
build-tools: 33.0.0
|
|
|
|
- name: Setup Godot
|
|
uses: chickensoft-games/setup-godot@v1
|
|
with:
|
|
version: ${{ env.GODOT_VERSION }}
|
|
use-dotnet: false
|
|
|
|
- name: Install export templates
|
|
run: |
|
|
echo "📦 Installing Godot export templates..."
|
|
mkdir -p ~/.local/share/godot/export_templates/${{ env.GODOT_VERSION }}.stable
|
|
wget -q https://github.com/godotengine/godot/releases/download/${{ env.GODOT_VERSION }}-stable/Godot_v${{ env.GODOT_VERSION }}-stable_export_templates.tpz
|
|
unzip -q Godot_v${{ env.GODOT_VERSION }}-stable_export_templates.tpz
|
|
mv templates/* ~/.local/share/godot/export_templates/${{ env.GODOT_VERSION }}.stable/
|
|
echo "✅ Export templates installed successfully"
|
|
|
|
- name: Create build directory
|
|
run: mkdir -p ${{ env.BUILD_DIR }}
|
|
|
|
- name: Import project assets
|
|
run: |
|
|
echo "📦 Importing project assets..."
|
|
godot --headless --verbose --editor --quit || true
|
|
sleep 2
|
|
|
|
- name: Build Android APK
|
|
run: |
|
|
echo "🏗️ Building Android APK..."
|
|
|
|
# Set ANDROID_HOME if not already set
|
|
export ANDROID_HOME=${ANDROID_HOME:-$ANDROID_SDK_ROOT}
|
|
|
|
godot --headless --verbose --export-${{ needs.prepare.outputs.build_type }} "Android" \
|
|
${{ env.BUILD_DIR }}/skelly-android-${{ needs.prepare.outputs.version }}.apk
|
|
|
|
# Verify build output
|
|
if [[ -f "${{ env.BUILD_DIR }}/skelly-android-${{ needs.prepare.outputs.version }}.apk" ]]; then
|
|
echo "✅ Android build successful"
|
|
ls -la ${{ env.BUILD_DIR }}/
|
|
|
|
# Show APK info
|
|
echo "📱 APK Information:"
|
|
file ${{ env.BUILD_DIR }}/skelly-android-${{ needs.prepare.outputs.version }}.apk
|
|
else
|
|
echo "❌ Android build failed"
|
|
exit 1
|
|
fi
|
|
|
|
- name: Upload Android build
|
|
uses: actions/upload-artifact@v3
|
|
with:
|
|
name: ${{ needs.prepare.outputs.artifact_name }}-android
|
|
path: ${{ env.BUILD_DIR }}/skelly-android-${{ needs.prepare.outputs.version }}.apk
|
|
retention-days: 7
|
|
compression-level: 0
|
|
|
|
# Summary job - creates release summary
|
|
summary:
|
|
name: Build Summary
|
|
runs-on: ubuntu-latest
|
|
needs: [prepare, build-windows, build-linux, build-macos, build-android]
|
|
if: always()
|
|
|
|
steps:
|
|
- name: Generate build summary
|
|
run: |
|
|
echo "🎮 Build Summary for ${{ needs.prepare.outputs.artifact_name }}"
|
|
echo "=================================="
|
|
echo ""
|
|
echo "📋 Configuration:"
|
|
echo " Version: ${{ needs.prepare.outputs.version }}"
|
|
echo " Build Type: ${{ needs.prepare.outputs.build_type }}"
|
|
echo " Platforms: ${{ needs.prepare.outputs.platforms }}"
|
|
echo ""
|
|
echo "📊 Build Results:"
|
|
|
|
platforms="${{ needs.prepare.outputs.platforms }}"
|
|
|
|
if [[ "$platforms" == *"windows"* ]]; then
|
|
windows_status="${{ needs.build-windows.result }}"
|
|
echo " 🪟 Windows: $windows_status"
|
|
fi
|
|
|
|
if [[ "$platforms" == *"linux"* ]]; then
|
|
linux_status="${{ needs.build-linux.result }}"
|
|
echo " 🐧 Linux: $linux_status"
|
|
fi
|
|
|
|
if [[ "$platforms" == *"macos"* ]]; then
|
|
macos_status="${{ needs.build-macos.result }}"
|
|
echo " 🍎 macOS: $macos_status"
|
|
fi
|
|
|
|
if [[ "$platforms" == *"android"* ]]; then
|
|
android_status="${{ needs.build-android.result }}"
|
|
echo " 🤖 Android: $android_status"
|
|
fi
|
|
|
|
echo ""
|
|
echo "📦 Artifacts are available for 7 days"
|
|
echo "🔗 Download from: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}"
|
|
|
|
- name: Check overall build status
|
|
run: |
|
|
# Check if any required builds failed
|
|
platforms="${{ needs.prepare.outputs.platforms }}"
|
|
failed_builds=()
|
|
|
|
if [[ "$platforms" == *"windows"* ]] && [[ "${{ needs.build-windows.result }}" != "success" ]]; then
|
|
failed_builds+=("Windows")
|
|
fi
|
|
|
|
if [[ "$platforms" == *"linux"* ]] && [[ "${{ needs.build-linux.result }}" != "success" ]]; then
|
|
failed_builds+=("Linux")
|
|
fi
|
|
|
|
if [[ "$platforms" == *"macos"* ]] && [[ "${{ needs.build-macos.result }}" != "success" ]]; then
|
|
failed_builds+=("macOS")
|
|
fi
|
|
|
|
if [[ "$platforms" == *"android"* ]] && [[ "${{ needs.build-android.result }}" != "success" ]]; then
|
|
failed_builds+=("Android")
|
|
fi
|
|
|
|
if [[ ${#failed_builds[@]} -gt 0 ]]; then
|
|
echo "❌ Build failed for: ${failed_builds[*]}"
|
|
exit 1
|
|
else
|
|
echo "✅ All builds completed successfully!"
|
|
fi
|