From 39bb1f9ddc089a8f6c2418b79ad2b163cc116f68 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 | 130 ++++++++++++------------------------ .github/workflows/ci.yml | 14 ++++ 2 files changed, 57 insertions(+), 87 deletions(-) create mode 100644 .github/workflows/ci.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index c0e5476..d71a8b4 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,97 +1,54 @@ # 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 ] + platform: [ windows, linux, macos, android ] + include: - # Linux - - identifier: linux-debug - name: Linux Debug - runner: ubuntu-20.04 - target: template_debug - platform: linux - arch: x86_64 + # Defaults + - runner: ubuntu-latest + - arch: x86_64 + - optimize: speed_trace - - identifier: linux-release - name: Linux Release - runner: ubuntu-20.04 - target: template_release - platform: linux - arch: x86_64 + # Special cases + - target: template_release + optimize: speed - # Windows - - identifier: windows-debug - name: Windows Debug - runner: ubuntu-20.04 - target: template_debug - platform: windows - arch: x86_64 + - platform: macos + arch: universal + runner: macos-latest - - identifier: windows-release - name: Windows Release - runner: ubuntu-20.04 - target: template_release - platform: windows + - platform: android arch: x86_64 + asdf: asdf - # Android Arm64 - - identifier: android-release - name: Android Release Arm64 - runner: ubuntu-20.04 - target: template_release - platform: android - arch: arm64 - - - identifier: android-debug - name: Android Debug Arm64 - runner: ubuntu-20.04 - target: template_debug - platform: android + - platform: android arch: arm64 - - # Android x86_64 - - identifier: android-release - name: Android Release x86_64 - runner: ubuntu-20.04 - target: template_release - platform: android - arch: x86_64 - - - identifier: android-debug - name: Android Debug x86_64 - runner: ubuntu-20.04 - target: template_debug - 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 + asdf: asdf steps: - name: (Windows) Install mingw64 - if: ${{ startsWith(matrix.identifier, 'windows-') }} + if: ${{ matrix.platform == 'windows' }} shell: sh run: | sudo apt-get install mingw-w64 @@ -99,19 +56,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 +87,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 +105,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 @@ -162,12 +120,10 @@ jobs: scons target='${{ matrix.target }}' platform='${{ matrix.platform }}' arch='${{ matrix.arch }}' -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 }} +