Skip to content

Commit

Permalink
[godot] GH extension build
Browse files Browse the repository at this point in the history
  • Loading branch information
badlogic committed Dec 11, 2024
1 parent 88b1c2c commit adcb119
Show file tree
Hide file tree
Showing 7 changed files with 486 additions and 23 deletions.
25 changes: 25 additions & 0 deletions .github/workflows/spine-godot-extension-v4-all.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: Build spine-godot GDExtension (All Godot 4.x versions)

on:
push:
paths:
- ".github/workflows/spine-godot.yml"
- 'spine-godot/**'
- 'spine-cpp/**'
workflow_dispatch:

jobs:
build-versions:
strategy:
matrix:
version:
[
{"tag": "4.3-stable", "version": "4.3.stable", "dev": false},
{"tag": "4.2.2-stable", "version": "4.2.2.stable", "dev": false},
]
uses: ./.github/workflows/spine-godot-extension-v4.yml
with:
godot_tag: ${{ matrix.version.tag }}
godot_version: ${{ matrix.version.version }}
dev: ${{ matrix.version.dev }}
secrets: inherit
281 changes: 281 additions & 0 deletions .github/workflows/spine-godot-extension-v4.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,281 @@
name: Build spine-godot GDExtension (Godot 4.x)

on:
workflow_call:
inputs:
godot_tag:
required: true
type: string
default: "Godot tag not specified!"
godot_version:
required: true
type: string
default: "Godot version not specified!"
dev:
required: true
type: boolean
default: false

env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_EC2_METADATA_DISABLED: true
GODOT_TAG: ${{ inputs.godot_tag }}
GODOT_VERSION: ${{ inputs.godot_version }}
DEV_BUILD: ${{ inputs.dev }}

jobs:
build-windows:
runs-on: windows-2022
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Setup python and scons
uses: ./.github/actions/setup-godot-deps-4

- name: Build GDExtension
shell: bash
run: |
./setup-extension.sh $GODOT_TAG $DEV
./build-extension.sh windows
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: gdextension-windows-${{ env.GODOT_TAG }}
path: example-v4-extension/bin/windows/*.dll

build-linux-x86_64:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Setup python and scons
uses: ./.github/actions/setup-godot-deps-4

- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install build-essential scons pkg-config libx11-dev libxcursor-dev libxinerama-dev libgl1-mesa-dev libglu-dev libasound2-dev libpulse-dev libudev-dev libxi-dev libxrandr-dev
- name: Build GDExtension
run: |
./setup-extension.sh $GODOT_TAG $DEV
./build-extension.sh linux
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: gdextension-linux-x86_64-${{ env.GODOT_TAG }}
path: example-v4-extension/bin/linux/*.so

build-linux-arm64:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Setup python and scons
uses: ./.github/actions/setup-godot-deps-4

- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install build-essential scons pkg-config gcc-aarch64-linux-gnu g++-aarch64-linux-gnu
- name: Build GDExtension
run: |
./setup-extension.sh $GODOT_TAG $DEV
./build-extension.sh linux arm64
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: gdextension-linux-arm64-${{ env.GODOT_TAG }}
path: example-v4-extension/bin/linux/*.so

build-macos:
runs-on: macos-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Setup python and scons
uses: ./.github/actions/setup-godot-deps-4

- name: Build GDExtension
run: |
./setup-extension.sh $GODOT_TAG $DEV
./build-extension.sh macos
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: gdextension-macos-${{ env.GODOT_TAG }}
path: example-v4-extension/bin/macos/macos.framework/*

build-ios:
runs-on: macos-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Setup python and scons
uses: ./.github/actions/setup-godot-deps-4

- name: Build GDExtension
run: |
./setup-extension.sh $GODOT_TAG $DEV
./build-extension.sh ios
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: gdextension-ios-${{ env.GODOT_TAG }}
path: example-v4-extension/bin/ios/*.xcframework/**/*

build-android:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Make apt sources.list use the default Ubuntu repositories
run: |
sudo rm -f /etc/apt/sources.list.d/*
sudo cp -f build/sources.lst /etc/apt/sources.list
sudo apt-get update
- name: Set up Java 17
uses: actions/setup-java@v1
with:
java-version: 17

- name: Setup python and scons
uses: ./.github/actions/setup-godot-deps-4

- name: Build GDExtension
run: |
./setup-extension.sh $GODOT_TAG $DEV
./build-extension.sh android
./build-extension.sh android x86_64
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: gdextension-android-${{ env.GODOT_TAG }}
path: example-v4-extension/bin/android/*.so

build-web:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Set up Emscripten latest
uses: mymindstorm/setup-emsdk@v11
with:
version: 3.1.26

- name: Setup python and scons
uses: ./.github/actions/setup-godot-deps-4

- name: Build GDExtension
run: |
./setup-extension.sh $GODOT_TAG $DEV
./build-extension.sh web
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: gdextension-web-${{ env.GODOT_TAG }}
path: example-v4-extension/bin/web/*.wasm

upload-to-s3:
needs: [build-windows, build-linux-x86_64, build-linux-arm64, build-macos, build-ios, build-android, build-web]
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Download windows artifact
uses: actions/download-artifact@v4
with:
name: gdextension-windows-${{ env.GODOT_TAG }}
path: artifacts/gdextension-windows-${{ env.GODOT_TAG }}

- name: Download linux-x86_64 artifact
uses: actions/download-artifact@v4
with:
name: gdextension-linux-x86_64-${{ env.GODOT_TAG }}
path: artifacts/gdextension-linux-x86_64-${{ env.GODOT_TAG }}

- name: Download linux-arm64 artifact
uses: actions/download-artifact@v4
with:
name: gdextension-linux-arm64-${{ env.GODOT_TAG }}
path: artifacts/gdextension-linux-arm64-${{ env.GODOT_TAG }}

- name: Download macos artifact
uses: actions/download-artifact@v4
with:
name: gdextension-macos-${{ env.GODOT_TAG }}
path: artifacts/gdextension-macos-${{ env.GODOT_TAG }}

- name: Download ios artifact
uses: actions/download-artifact@v4
with:
name: gdextension-ios-${{ env.GODOT_TAG }}
path: artifacts/gdextension-ios-${{ env.GODOT_TAG }}

- name: Download android artifact
uses: actions/download-artifact@v4
with:
name: gdextension-android-${{ env.GODOT_TAG }}
path: artifacts/gdextension-android-${{ env.GODOT_TAG }}

- name: Download web artifact
uses: actions/download-artifact@v4
with:
name: gdextension-web-${{ env.GODOT_TAG }}
path: artifacts/gdextension-web-${{ env.GODOT_TAG }}

- name: Package and upload artifacts
shell: bash
if: env.AWS_ACCESS_KEY_ID != null
run: |
BRANCH=${GITHUB_REF#refs/heads/}
echo "branch: $BRANCH"
cd artifacts
# Ensure gdextension file is in root
cp ../spine_godot_extension.gdextension ./
# Create directories matching the expected structure
mkdir -p bin/{windows,linux,macos/macos.framework,ios,android,web}
# Move artifacts to their correct locations
mv gdextension-windows-$GODOT_TAG/* bin/windows/
mv gdextension-linux-x86_64-$GODOT_TAG/* bin/linux/
mv gdextension-linux-arm64-$GODOT_TAG/* bin/linux/
mv gdextension-macos-$GODOT_TAG/* bin/macos/macos.framework/
mv gdextension-ios-$GODOT_TAG/* bin/ios/
mv gdextension-android-$GODOT_TAG/* bin/android/
mv gdextension-web-$GODOT_TAG/* bin/web/
# Create the final zip with branch and tag
zip -r ../spine-godot-extension-$BRANCH-$GODOT_TAG.zip spine_godot_extension.gdextension bin/
cd ..
aws s3 cp spine-godot-extension-$BRANCH-$GODOT_TAG.zip s3://spine-godot/$BRANCH/$GODOT_TAG/
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -218,3 +218,4 @@ spine-godot/.idea
spine-godot/build/version.txt
spine-godot/vc140.pdb
spine-godot/example-v4-extension/bin
spine-godot/example-v4-extension/MoltenVK.xcframework
Loading

0 comments on commit adcb119

Please sign in to comment.