From 02a2607046d32ee89908134637804e9ec3cbbdf4 Mon Sep 17 00:00:00 2001 From: Marvin Ewald Date: Sun, 14 Jul 2024 15:34:44 +0200 Subject: [PATCH] Update build workflow --- .github/workflows/build.yml | 139 ++++++++++++++---------------------- .github/workflows/ci.yml | 14 ++++ 2 files changed, 68 insertions(+), 85 deletions(-) create mode 100644 .github/workflows/ci.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index c0e5476..61711ff 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,97 +1,67 @@ # Adapted from https://github.com/nathanfranke/gdextension/blob/main/.github/workflows/build.yml name: Builds on: - push: - branches: [ "master" ] - pull_request: - branches: [ "master" ] + workflow_dispatch: + inputs: + git-ref: + description: A commit, branch or tag to build. + type: string + required: true + workflow_call: + inputs: + git-ref: + description: A commit, branch or tag to build. + type: string + required: true jobs: build: runs-on: ${{ matrix.runner }} - name: ${{ matrix.name }} + name: ${{ matrix.platform }} ${{ matrix.target }} ${{ matrix.arch }} ${{ matrix.optimize }} strategy: fail-fast: false matrix: + target: [ template_debug, template_release ] + identifier: [ windows, linux, macos, android, android_arm64 ] + include: - # Linux - - identifier: linux-debug - name: Linux Debug - runner: ubuntu-20.04 - target: template_debug - platform: linux - arch: x86_64 + # Defaults + - runner: ubuntu-latest + - optimize: speed + - arch: x86_64 - - identifier: linux-release - name: Linux Release - runner: ubuntu-20.04 - target: template_release - platform: linux - arch: x86_64 + # Debug build settings + - target: template_debug + optimize: speed_trace - # Windows - - identifier: windows-debug - name: Windows Debug - runner: ubuntu-20.04 - target: template_debug + # Map identifiers to platforms + special settings + - identifier: windows platform: windows - arch: x86_64 - - identifier: windows-release - name: Windows Release - runner: ubuntu-20.04 - target: template_release - platform: windows - arch: x86_64 - - # Android Arm64 - - identifier: android-release - name: Android Release Arm64 - runner: ubuntu-20.04 - target: template_release - platform: android - arch: arm64 + - identifier: macos + platform: macos + runner: macos-latest + arch: universal - - identifier: android-debug - name: Android Debug Arm64 - runner: ubuntu-20.04 - target: template_debug - platform: android - arch: arm64 + - identifier: linux + platform: linux - # Android x86_64 - - identifier: android-release - name: Android Release x86_64 - runner: ubuntu-20.04 - target: template_release + - identifier: android platform: android - arch: x86_64 - - identifier: android-debug - name: Android Debug x86_64 - runner: ubuntu-20.04 - target: template_debug + - identifier: android_arm64 platform: android - arch: x86_64 - - # Mac - - identifier: macos-debug - name: macOS (universal) Debug - runner: macos-latest - target: template_debug - platform: macos - arch: universal - - - identifier: macos-release - name: macOS (universal) Release - runner: macos-latest - target: template_release - platform: macos - arch: universal + arch: arm64 steps: + - name: Check settings + if: ${{ matrix.platform == '' || matrix.target == '' || matrix.runner == '' || matrix.optimize == '' || matrix.arch == ''}} + run: | + echo "One of the matrix values is not set." + exit 1 + - name: (Windows) Install mingw64 - if: ${{ startsWith(matrix.identifier, 'windows-') }} + if: ${{ matrix.platform == 'windows' }} shell: sh run: | sudo apt-get install mingw-w64 @@ -99,19 +69,19 @@ jobs: sudo update-alternatives --set x86_64-w64-mingw32-g++ /usr/bin/x86_64-w64-mingw32-g++-posix - name: (Android) Install JDK 17 - if: ${{ startsWith(matrix.identifier, 'android-') }} + if: ${{ matrix.platform == 'android' }} uses: actions/setup-java@v3 with: java-version: 17 distribution: temurin - name: (Android) Install Android SDK - if: ${{ startsWith(matrix.identifier, 'android-') }} + if: ${{ matrix.platform == 'android' }} uses: android-actions/setup-android@v3 # From Godot docs, might not be necessary. #- name: (Android) Install Android Tools - # if: ${{ startsWith(matrix.identifier, 'android-') }} + # if: ${{ matrix.platform == 'android' }} # shell: sh # run: | # "$ANDROID_SDK_ROOT"/cmdline-tools/latest/bin/sdkmanager --sdk_root="$ANDROID_SDK_ROOT" "platform-tools" "build-tools;30.0.3" "platforms;android-29" "cmdline-tools;latest" "cmake;3.10.2.4988404" @@ -130,13 +100,14 @@ jobs: shell: bash run: | python -c "import sys; print(sys.version)" - python -m pip install scons + python -m pip install scons==4.7.0 scons --version - name: Checkout project - uses: actions/checkout@v2 + uses: actions/checkout@v4 with: submodules: recursive + ref: ${{ inputs.git-ref }} # TODO: Cache doesn't work yet. SCons rebuilds the objects even if they already exist. Could be caused by modification dates or extension_api.json. # fetch-depth: 0 May be needed for cache. See: . @@ -147,11 +118,11 @@ jobs: # ${{ github.workspace }}/.scons-cache/ # ${{ github.workspace }}/**/.sconsign.dblite # ${{ github.workspace }}/godot-cpp/gen/ -# key: ${{ matrix.identifier }}-${{ github.ref }}-${{ github.sha }} +# key: ${{ matrix.platform }}-${{ github.ref }}-${{ github.sha }} # restore-keys: | -# ${{ matrix.identifier }}-${{ github.ref }}-${{ github.sha }} -# ${{ matrix.identifier }}-${{ github.ref }} -# ${{ matrix.identifier }} +# ${{ matrix.platform }}-${{ github.ref }}-${{ github.sha }} +# ${{ matrix.platform }}-${{ github.ref }} +# ${{ matrix.platform }} - name: Compile extension shell: sh @@ -159,15 +130,13 @@ jobs: # SCONS_CACHE: '${{ github.workspace }}/.scons-cache/' # SCONS_CACHE_LIMIT: 8192 run: | - scons target='${{ matrix.target }}' platform='${{ matrix.platform }}' arch='${{ matrix.arch }}' -j2 + scons target='${{ matrix.target }}' platform='${{ matrix.platform }}' arch='${{ matrix.arch }}' optimize=${{ matrix.optimize }} -j2 ls -l demo/addons/*/bin/ - - name: Copy extra files to addon + - name: Prepare files for publish shell: sh run: | - for addon in ${{ github.workspace }}/demo/addons/*/; do - cp -n '${{ github.workspace }}/README.md' '${{ github.workspace }}/LICENSE' "$addon" - done + cp -n '${{ github.workspace }}/README.md' '${{ github.workspace }}/LICENSE' '${{ github.workspace }}/demo/addons/ropesim/' - name: Upload artifact uses: actions/upload-artifact@v2 diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..c4487fa --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,14 @@ +name: CI +on: + push: + # branches: [ master ] + pull_request: + # branches: [ master ] + +jobs: + ci: + name: "CI" + uses: ./.github/workflows/build.yml + with: + git-ref: ${{ github.ref }} +