Use matrix notation in build.yml to reduce clutter and update Ubuntu image #65
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build GDExtension | |
on: | |
workflow_call: | |
push: | |
pull_request: | |
merge_group: | |
jobs: | |
build: | |
strategy: | |
fail-fast: false | |
matrix: | |
float-precision: [single, double] | |
target-type: [template_debug] # you can add "template_release" here | |
target: | |
[ | |
{ platform: linux, arch: x86_64, os: ubuntu-24.04 }, | |
{ platform: windows, arch: x86_64, os: windows-latest }, | |
{ platform: windows, arch: x86_32, os: windows-latest }, | |
{ platform: macos, arch: universal, os: macos-latest }, | |
{ platform: ios, arch: arm64, os: macos-latest }, | |
{ platform: android, arch: arm64, os: ubuntu-24.04 }, | |
{ platform: android, arch: arm32, os: ubuntu-24.04 }, | |
{ platform: android, arch: x86_64, os: ubuntu-24.04 }, | |
{ platform: android, arch: x86_32, os: ubuntu-24.04 }, | |
{ platform: web, arch: wasm32, os: ubuntu-24.04 }, | |
] | |
include: # Also build a release version for these specific targets | |
- float-precision: single | |
target-type: template_release | |
target: { platform: linux, arch: x86_64, os: ubuntu-24.04 } | |
- float-precision: double | |
target-type: template_release | |
target: { platform: linux, arch: x86_64, os: ubuntu-24.04 } | |
runs-on: ${{ matrix.target.os }} | |
steps: | |
# Clone this repository | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
submodules: true | |
# Lint | |
#- name: Setup clang-format | |
# shell: bash | |
# run: | | |
# python -m pip install clang-format | |
#- name: Run clang-format | |
# shell: bash | |
# run: | | |
# clang-format src/** --dry-run --Werror | |
# Setup dependencies | |
- name: Setup godot-cpp | |
uses: ./godot-cpp/.github/actions/setup-godot-cpp | |
with: | |
platform: ${{ matrix.target.platform }} | |
em-version: 3.1.62 | |
# Build GDExtension (with caches) | |
- name: Cache .scons_cache | |
uses: actions/cache@v4 | |
with: | |
path: ${{ github.workspace }}/.scons-cache/ | |
key: ${{ matrix.target.platform }}_${{ matrix.target.arch }}_${{ matrix.float-precision }}_${{ matrix.target-type }}_cache | |
- name: Build GDExtension Debug Build | |
shell: sh | |
env: | |
SCONS_CACHE: ${{ github.workspace }}/.scons-cache/ | |
run: | | |
scons target=${{ matrix.target-type }} platform=${{ matrix.target.platform }} arch=${{ matrix.target.arch }} precision=${{ matrix.float-precision }} | |
# Sign the binary (macOS only) | |
- name: Mac Sign | |
# Disable sign if secrets are not set | |
if: ${{ matrix.target.platform == 'macos' && env.APPLE_CERT_BASE64 }} | |
env: | |
APPLE_CERT_BASE64: ${{ secrets.APPLE_CERT_BASE64 }} | |
uses: ./.github/actions/sign | |
with: | |
FRAMEWORK_PATH: bin/macos/macos.framework | |
APPLE_CERT_BASE64: ${{ secrets.APPLE_CERT_BASE64 }} | |
APPLE_CERT_PASSWORD: ${{ secrets.APPLE_CERT_PASSWORD }} | |
APPLE_DEV_PASSWORD: ${{ secrets.APPLE_DEV_PASSWORD }} | |
APPLE_DEV_ID: ${{ secrets.APPLE_DEV_ID }} | |
APPLE_DEV_TEAM_ID: ${{ secrets.APPLE_DEV_TEAM_ID }} | |
APPLE_DEV_APP_ID: ${{ secrets.APPLE_DEV_APP_ID }} | |
# Clean up compilation files | |
- name: Windows - Delete compilation files | |
if: ${{ matrix.target.platform == 'windows' }} | |
shell: pwsh | |
run: | | |
Remove-Item bin/* -Include *.exp,*.lib,*.pdb -Force | |
# Upload the build | |
- name: Upload Artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: godot-cpp-template-${{ matrix.target.platform }}-${{ matrix.target.arch }}-${{ matrix.float-precision }}-${{ matrix.target-type }} | |
path: | | |
${{ github.workspace }}/bin/** | |
# Merges all the build artifacts together into a single godot-cpp-template artifact. | |
# If you comment out this step, all the builds will be uploaded individually. | |
merge: | |
runs-on: ubuntu-20.04 | |
needs: build | |
steps: | |
- name: Merge Artifacts | |
uses: actions/upload-artifact/merge@v4 | |
with: | |
name: godot-cpp-template | |
pattern: godot-cpp-template-* | |
delete-merged: true |