diff --git a/.gitea/workflows/build.yml b/.gitea/workflows/build.yml index 74065e3..c02b526 100644 --- a/.gitea/workflows/build.yml +++ b/.gitea/workflows/build.yml @@ -4,10 +4,13 @@ name: Build Game # # Features: # - Manual trigger with individual platform checkboxes +# - Configurable version override (defaults to auto-generated) +# - Configurable tool versions (Godot, Java, Android API, etc.) +# - Flexible runner OS selection # - Tag-based automatic builds for releases # - Multi-platform builds (Windows, Linux, macOS, Android) # - Artifact storage for one week -# - Configurable build options +# - Comprehensive build configuration options on: # Manual trigger with platform selection @@ -33,6 +36,11 @@ on: required: false default: false type: boolean + version: + description: 'Version (leave empty for auto-generated)' + required: false + default: '' + type: string build_type: description: 'Build type' required: true @@ -41,9 +49,25 @@ on: options: - release - debug - version_override: - description: 'Override version (optional)' + godot_version: + description: 'Godot version (leave empty for default)' required: false + default: '' + type: string + runner_os: + description: 'Runner OS (leave empty for default ubuntu-latest)' + required: false + default: '' + type: string + java_version: + description: 'Java version (leave empty for default)' + required: false + default: '' + type: string + android_api_level: + description: 'Android API level (leave empty for default)' + required: false + default: '' type: string # Automatic trigger on git tags (for releases) @@ -53,15 +77,39 @@ on: - 'release-*' # Release tags env: + # Core Configuration GODOT_VERSION: "4.4.1" PROJECT_NAME: "Skelly" BUILD_DIR: "builds" + DEFAULT_VERSION: "1.0.0-dev" + + # GitHub Actions Versions + ACTIONS_CHECKOUT_VERSION: "v4" + ACTIONS_CACHE_VERSION: "v4" + ACTIONS_UPLOAD_ARTIFACT_VERSION: "v3" + ACTIONS_SETUP_JAVA_VERSION: "v4" + + # Third-party Actions Versions + CHICKENSOFT_SETUP_GODOT_VERSION: "v1" + ANDROID_ACTIONS_SETUP_ANDROID_VERSION: "v3" + + # Runner Configuration + RUNNER_OS: "ubuntu-latest" + + # Java Configuration + JAVA_DISTRIBUTION: "temurin" + JAVA_VERSION: "17" + + # Android Configuration + ANDROID_API_LEVEL: "33" + ANDROID_BUILD_TOOLS_VERSION: "33.0.0" + ANDROID_CMDLINE_TOOLS_VERSION: "latest" jobs: # Preparation job - determines build configuration prepare: name: Prepare Build - runs-on: ubuntu-latest + runs-on: ${{ env.RUNNER_OS }} outputs: platforms: ${{ steps.config.outputs.platforms }} build_type: ${{ steps.config.outputs.build_type }} @@ -70,13 +118,35 @@ jobs: steps: - name: Checkout repository - uses: actions/checkout@v4 + uses: actions/checkout@${{ env.ACTIONS_CHECKOUT_VERSION }} with: fetch-depth: 0 - name: Configure build parameters id: config run: | + # Override environment variables with user inputs if provided + if [[ -n "${{ github.event.inputs.godot_version }}" ]]; then + echo "GODOT_VERSION=${{ github.event.inputs.godot_version }}" >> $GITHUB_ENV + echo "🔧 Using custom Godot version: ${{ github.event.inputs.godot_version }}" + fi + + if [[ -n "${{ github.event.inputs.runner_os }}" ]]; then + echo "RUNNER_OS=${{ github.event.inputs.runner_os }}" >> $GITHUB_ENV + echo "🔧 Using custom runner OS: ${{ github.event.inputs.runner_os }}" + fi + + if [[ -n "${{ github.event.inputs.java_version }}" ]]; then + echo "JAVA_VERSION=${{ github.event.inputs.java_version }}" >> $GITHUB_ENV + echo "🔧 Using custom Java version: ${{ github.event.inputs.java_version }}" + fi + + if [[ -n "${{ github.event.inputs.android_api_level }}" ]]; then + echo "ANDROID_API_LEVEL=${{ github.event.inputs.android_api_level }}" >> $GITHUB_ENV + echo "ANDROID_BUILD_TOOLS_VERSION=${{ github.event.inputs.android_api_level }}.0.0" >> $GITHUB_ENV + echo "🔧 Using custom Android API level: ${{ github.event.inputs.android_api_level }}" + fi + # Determine platforms to build if [[ "${{ github.event_name }}" == "workflow_dispatch" ]]; then # Build platforms array from individual checkboxes @@ -97,25 +167,37 @@ jobs: platforms="${platforms%,}" build_type="${{ github.event.inputs.build_type }}" - version_override="${{ github.event.inputs.version_override }}" + user_version="${{ github.event.inputs.version }}" else # Tag-triggered build - build all platforms platforms="windows,linux,macos,android" build_type="release" - version_override="" + user_version="" fi - # Determine version - if [[ -n "$version_override" ]]; then - version="$version_override" + # Determine version with improved logic + if [[ -n "$user_version" ]]; then + # User provided explicit version + version="$user_version" + echo "🏷️ Using user-specified version: $version" elif [[ "${{ github.ref_type }}" == "tag" ]]; then + # Tag-triggered build - use tag name version="${{ github.ref_name }}" - else - # Generate version from git info + echo "🏷️ Using git tag version: $version" + elif [[ "${{ github.event_name }}" == "workflow_dispatch" ]]; then + # Manual dispatch without version - use default + 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}" + version="${{ env.DEFAULT_VERSION }}-${branch_name}-${commit_short}-${timestamp}" + echo "🏷️ Using auto-generated version: $version" + else + # Fallback for other triggers + commit_short=$(git rev-parse --short HEAD) + branch_name="${{ github.ref_name }}" + timestamp=$(date +%Y%m%d-%H%M) + version="${{ env.DEFAULT_VERSION }}-${branch_name}-${commit_short}-${timestamp}" + echo "🏷️ Using fallback version: $version" fi # Create artifact name @@ -131,17 +213,24 @@ jobs: echo " Build Type: ${build_type}" echo " Version: ${version}" echo " Artifact: ${artifact_name}" + echo "" + echo "🔧 Tool Versions:" + echo " Godot: ${GODOT_VERSION}" + echo " Runner OS: ${RUNNER_OS}" + echo " Java: ${JAVA_VERSION}" + echo " Android API: ${ANDROID_API_LEVEL}" + echo " Android Build Tools: ${ANDROID_BUILD_TOOLS_VERSION}" # Setup export templates (shared across all platform builds) setup-templates: name: Setup Export Templates - runs-on: ubuntu-latest + runs-on: ${{ env.RUNNER_OS }} needs: prepare steps: - name: Cache export templates id: cache-templates - uses: actions/cache@v4 + uses: actions/cache@${{ env.ACTIONS_CACHE_VERSION }} with: path: ~/.local/share/godot/export_templates key: godot-templates-${{ env.GODOT_VERSION }} @@ -150,7 +239,7 @@ jobs: - name: Setup Godot if: steps.cache-templates.outputs.cache-hit != 'true' - uses: chickensoft-games/setup-godot@v1 + uses: chickensoft-games/setup-godot@${{ env.CHICKENSOFT_SETUP_GODOT_VERSION }} with: version: ${{ env.GODOT_VERSION }} use-dotnet: false @@ -174,22 +263,22 @@ jobs: # Windows build job build-windows: name: Build Windows - runs-on: ubuntu-latest + runs-on: ${{ env.RUNNER_OS }} needs: [prepare, setup-templates] if: contains(needs.prepare.outputs.platforms, 'windows') steps: - name: Checkout repository - uses: actions/checkout@v4 + uses: actions/checkout@${{ env.ACTIONS_CHECKOUT_VERSION }} - name: Setup Godot - uses: chickensoft-games/setup-godot@v1 + uses: chickensoft-games/setup-godot@${{ env.CHICKENSOFT_SETUP_GODOT_VERSION }} with: version: ${{ env.GODOT_VERSION }} use-dotnet: false - name: Restore export templates cache - uses: actions/cache@v4 + uses: actions/cache@${{ env.ACTIONS_CACHE_VERSION }} with: path: ~/.local/share/godot/export_templates key: godot-templates-${{ env.GODOT_VERSION }} @@ -221,7 +310,7 @@ jobs: fi - name: Upload Windows build - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@${{ env.ACTIONS_UPLOAD_ARTIFACT_VERSION }} with: name: ${{ needs.prepare.outputs.artifact_name }}-windows path: ${{ env.BUILD_DIR }}/skelly-windows-${{ needs.prepare.outputs.version }}.exe @@ -231,22 +320,22 @@ jobs: # Linux build job build-linux: name: Build Linux - runs-on: ubuntu-latest + runs-on: ${{ env.RUNNER_OS }} needs: [prepare, setup-templates] if: contains(needs.prepare.outputs.platforms, 'linux') steps: - name: Checkout repository - uses: actions/checkout@v4 + uses: actions/checkout@${{ env.ACTIONS_CHECKOUT_VERSION }} - name: Setup Godot - uses: chickensoft-games/setup-godot@v1 + uses: chickensoft-games/setup-godot@${{ env.CHICKENSOFT_SETUP_GODOT_VERSION }} with: version: ${{ env.GODOT_VERSION }} use-dotnet: false - name: Restore export templates cache - uses: actions/cache@v4 + uses: actions/cache@${{ env.ACTIONS_CACHE_VERSION }} with: path: ~/.local/share/godot/export_templates key: godot-templates-${{ env.GODOT_VERSION }} @@ -281,7 +370,7 @@ jobs: fi - name: Upload Linux build - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@${{ env.ACTIONS_UPLOAD_ARTIFACT_VERSION }} with: name: ${{ needs.prepare.outputs.artifact_name }}-linux path: ${{ env.BUILD_DIR }}/skelly-linux-${{ needs.prepare.outputs.version }}.x86_64 @@ -291,22 +380,22 @@ jobs: # macOS build job build-macos: name: Build macOS - runs-on: ubuntu-latest + runs-on: ${{ env.RUNNER_OS }} needs: [prepare, setup-templates] if: contains(needs.prepare.outputs.platforms, 'macos') steps: - name: Checkout repository - uses: actions/checkout@v4 + uses: actions/checkout@${{ env.ACTIONS_CHECKOUT_VERSION }} - name: Setup Godot - uses: chickensoft-games/setup-godot@v1 + uses: chickensoft-games/setup-godot@${{ env.CHICKENSOFT_SETUP_GODOT_VERSION }} with: version: ${{ env.GODOT_VERSION }} use-dotnet: false - name: Restore export templates cache - uses: actions/cache@v4 + uses: actions/cache@${{ env.ACTIONS_CACHE_VERSION }} with: path: ~/.local/share/godot/export_templates key: godot-templates-${{ env.GODOT_VERSION }} @@ -338,7 +427,7 @@ jobs: fi - name: Upload macOS build - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@${{ env.ACTIONS_UPLOAD_ARTIFACT_VERSION }} with: name: ${{ needs.prepare.outputs.artifact_name }}-macos path: ${{ env.BUILD_DIR }}/skelly-macos-${{ needs.prepare.outputs.version }}.zip @@ -348,37 +437,46 @@ jobs: # Android build job build-android: name: Build Android - runs-on: ubuntu-latest + runs-on: ${{ env.RUNNER_OS }} needs: [prepare, setup-templates] if: contains(needs.prepare.outputs.platforms, 'android') steps: - name: Checkout repository - uses: actions/checkout@v4 + uses: actions/checkout@${{ env.ACTIONS_CHECKOUT_VERSION }} - name: Setup Java - uses: actions/setup-java@v4 + uses: actions/setup-java@${{ env.ACTIONS_SETUP_JAVA_VERSION }} with: - distribution: 'temurin' - java-version: '17' + distribution: ${{ env.JAVA_DISTRIBUTION }} + java-version: ${{ env.JAVA_VERSION }} - name: Setup Android SDK - uses: android-actions/setup-android@v3 + uses: android-actions/setup-android@${{ env.ANDROID_ACTIONS_SETUP_ANDROID_VERSION }} with: - api-level: 33 - build-tools: 33.0.0 + api-level: ${{ env.ANDROID_API_LEVEL }} + build-tools: ${{ env.ANDROID_BUILD_TOOLS_VERSION }} - - name: Configure Android SDK for Godot + - name: Install Android Build Tools run: | - echo "🔧 Configuring Android SDK for Godot..." + echo "🔧 Installing Android Build Tools..." # Set Android environment variables export ANDROID_HOME=${ANDROID_SDK_ROOT} - export ANDROID_SDK_ROOT=${ANDROID_SDK_ROOT} - echo "ANDROID_HOME=${ANDROID_SDK_ROOT}" >> $GITHUB_ENV echo "ANDROID_SDK_ROOT=${ANDROID_SDK_ROOT}" >> $GITHUB_ENV + # Install build-tools using sdkmanager + yes | ${ANDROID_SDK_ROOT}/cmdline-tools/${{ env.ANDROID_CMDLINE_TOOLS_VERSION }}/bin/sdkmanager --licenses || true + ${ANDROID_SDK_ROOT}/cmdline-tools/${{ env.ANDROID_CMDLINE_TOOLS_VERSION }}/bin/sdkmanager "build-tools;${{ env.ANDROID_BUILD_TOOLS_VERSION }}" + ${ANDROID_SDK_ROOT}/cmdline-tools/${{ env.ANDROID_CMDLINE_TOOLS_VERSION }}/bin/sdkmanager "platforms;android-${{ env.ANDROID_API_LEVEL }}" + + - name: Verify Android SDK Configuration + run: | + echo "📱 Verifying Android SDK setup..." + echo "📱 Using API Level: ${{ env.ANDROID_API_LEVEL }}" + echo "📱 Using Build Tools: ${{ env.ANDROID_BUILD_TOOLS_VERSION }}" + # Verify SDK installation echo "📱 Android SDK Location: ${ANDROID_SDK_ROOT}" ls -la ${ANDROID_SDK_ROOT}/ @@ -387,8 +485,16 @@ jobs: echo "📱 Platforms:" ls -la ${ANDROID_SDK_ROOT}/platforms/ || echo "No platforms directory" + # Verify apksigner exists + if [ -f "${ANDROID_SDK_ROOT}/build-tools/${{ env.ANDROID_BUILD_TOOLS_VERSION }}/apksigner" ]; then + echo "✅ apksigner found at ${ANDROID_SDK_ROOT}/build-tools/${{ env.ANDROID_BUILD_TOOLS_VERSION }}/apksigner" + else + echo "❌ apksigner not found!" + exit 1 + fi + - name: Setup Godot - uses: chickensoft-games/setup-godot@v1 + uses: chickensoft-games/setup-godot@${{ env.CHICKENSOFT_SETUP_GODOT_VERSION }} with: version: ${{ env.GODOT_VERSION }} use-dotnet: false @@ -417,7 +523,7 @@ jobs: echo "✅ Godot Android configuration complete" - name: Restore export templates cache - uses: actions/cache@v4 + uses: actions/cache@${{ env.ACTIONS_CACHE_VERSION }} with: path: ~/.local/share/godot/export_templates key: godot-templates-${{ env.GODOT_VERSION }} @@ -439,7 +545,9 @@ jobs: # Verify Android environment echo "📱 Android SDK: ${ANDROID_SDK_ROOT}" - echo "📱 Build Tools: $(ls ${ANDROID_SDK_ROOT}/build-tools/)" + echo "📱 API Level: ${{ env.ANDROID_API_LEVEL }}" + echo "📱 Build Tools Version: ${{ env.ANDROID_BUILD_TOOLS_VERSION }}" + echo "📱 Available Build Tools: $(ls ${ANDROID_SDK_ROOT}/build-tools/)" godot --headless --verbose --export-${{ needs.prepare.outputs.build_type }} "Android" \ ${{ env.BUILD_DIR }}/skelly-android-${{ needs.prepare.outputs.version }}.apk @@ -458,7 +566,7 @@ jobs: fi - name: Upload Android build - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@${{ env.ACTIONS_UPLOAD_ARTIFACT_VERSION }} with: name: ${{ needs.prepare.outputs.artifact_name }}-android path: ${{ env.BUILD_DIR }}/skelly-android-${{ needs.prepare.outputs.version }}.apk @@ -468,7 +576,7 @@ jobs: # Summary job - creates release summary summary: name: Build Summary - runs-on: ubuntu-latest + runs-on: ${{ env.RUNNER_OS }} needs: [prepare, setup-templates, build-windows, build-linux, build-macos, build-android] if: always()