Skip to content

Add Android and Linux support #150

Add Android and Linux support

Add Android and Linux support #150

Workflow file for this run

# Workflow to automatically compile a Linux/Windows library on commit/push
name: Build on push
# Controls when the action will run. Triggers the workflow on push or pull request
# events, but only for the main branch we'll create .zip files
on:
[push, pull_request]
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# This job builds the plugin for our target platforms
build:
name: Building for ${{ matrix.platform }} (${{ matrix.os }})
runs-on: ${{ matrix.os }}
strategy:
fail-fast: true
matrix:
include:
# Unsupported platforms are commented out.
- name: 🐧 Linux (GCC)
os: ubuntu-20.04
platform: linux
artifact-name: gdtiltfive.linux
artifact-path: |
build/bin/linux/x86_64/libgdtiltfive.linux.template_debug.x86_64.so
build/bin/linux/x86_64/libgdtiltfive.linux.template_release.x86_64.so
extension/TiltFiveNDK/lib/linux/x86_64/libTiltFiveNative.so
- name: 🏁 Windows (x86_64, MSVC)
os: windows-2019
platform: windows
artifact-name: gdtiltfive.windows
artifact-path: |
build/bin/windows/x86_64/libgdtiltfive.windows.template_debug.x86_64.dll
build/bin/windows/x86_64/libgdtiltfive.windows.template_release.x86_64.dll
extension/TiltFiveNDK/lib/win/x86_64/TiltFiveNative.dll
#- name: 🍎 macOS (universal)
# os: macos-11
# platform: macos
# flags: arch=universal
# artifact-name: gdtiltfive.macos
# artifact-path: build/bin/libgdtiltfive.macos.*
- name: πŸ€– Android (arm64)
os: ubuntu-20.04
platform: android
#flags: ANDROID_NDK_ROOT=$ANDROID_NDK_LATEST_HOME arch=arm64
artifact-name: gdtiltfive.android
artifact-path: |
build/bin/android/arm64/libgdtiltfive.android.*
androidplugin/plugin/build/outputs/aar/gdtiltfive*
#- name: 🍏 iOS (arm64)
# os: macos-11
# platform: ios
# flags: arch=arm64
# artifact-name: gdtiltfive.ios
# artifact-path: build/bin/libgdtiltfive.ios.*
# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- name: Setup actions
uses: actions/checkout@v3
with:
submodules: 'recursive'
- name: Set up Python (for SCons)
uses: actions/setup-python@v4
with:
python-version: '3.x'
- name: Linux dependencies
if: ${{ matrix.platform == 'linux' }}
run: |
sudo apt-get update -qq
sudo apt-get install -qqq build-essential pkg-config
- name: Set up GCC
if: ${{ matrix.platform == 'linux' }}
uses: egor-tensin/setup-gcc@v1
with:
version: 11
platform: x64
- name: Android dependencies
if: ${{ matrix.platform == 'android' }}
uses: nttld/setup-ndk@v1
id: setup-ndk
with:
ndk-version: r26c
add-to-path: false
- name: Install scons
run: |
python -m pip install scons==4.0.0
- name: Build debug build
run: |
scons platform=${{ matrix.platform }} target=template_debug ${{ matrix.flags }} --no-gradle
env:
ANDROID_NDK_ROOT: ${{ steps.setup-ndk.outputs.ndk-path }}
- name: Build release build
run: |
scons platform=${{ matrix.platform }} target=template_release ${{ matrix.flags }} --no-gradle
env:
ANDROID_NDK_ROOT: ${{ steps.setup-ndk.outputs.ndk-path }}
- name: Set up Java
if: ${{ matrix.platform == 'android' }}
uses: actions/setup-java@v4
with:
distribution: 'zulu' # See 'Supported distributions' for available options
java-version: '17'
- name: Gradle build
if: ${{ matrix.platform == 'android' }}
run: |
mkdir plugin/libs
cp ../extension/TiltFiveNDK/lib/android/TiltFiveAndroidClient.jar plugin/libs/TiltFiveAndroidClient.jar
chmod +x ./gradlew
./gradlew build
working-directory: ./androidplugin
- name: Upload artifact
uses: actions/upload-artifact@v3
with:
name: ${{ matrix.artifact-name }}
path: ${{ matrix.artifact-path }}
if-no-files-found: error
# This job collects the build output and assembles the final asset (artifact)
asset:
name: Assembling the asset (artifact)
runs-on: ubuntu-20.04
needs: build
permissions:
contents: write
if: github.event_name == 'push' && (github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags'))
# Steps represent a sequence of tasks that will be executed as part of the job
steps:
- name: Setup actions
uses: actions/checkout@v3
with:
path: source
- name: Download all workflow run artifacts
uses: actions/download-artifact@v3
- name: Copy files to destination for gdscript
run: |
mkdir plugin
mkdir plugin/addons
cp -r source/example.gd/addons/tiltfive plugin/addons
cp source/LICENSE.txt plugin/addons/tiltfive
cp source/CONTRIBUTORS.md plugin/addons/tiltfive
cp source/CHANGES.md plugin/addons/tiltfive
mkdir plugin/addons/tiltfive/bin
mkdir plugin/addons/tiltfive/bin/linux
mkdir plugin/addons/tiltfive/bin/linux/x86_64
mkdir plugin/addons/tiltfive/bin/windows
mkdir plugin/addons/tiltfive/bin/windows/x86_64
mkdir plugin/addons/tiltfive/bin/android/
mkdir plugin/addons/tiltfive/bin/android/arm64
cp gdtiltfive.linux/build/bin/linux/x86_64/*.so plugin/addons/tiltfive/bin/linux/x86_64/
cp gdtiltfive.linux/extension/TiltFiveNDK/lib/linux/x86_64/*.so plugin/addons/tiltfive/bin/linux/x86_64/
cp gdtiltfive.windows/build/bin/windows/x86_64/*.dll plugin/addons/tiltfive/bin/windows/x86_64/
cp gdtiltfive.windows/extension/TiltFiveNDK/lib/win/x86_64/*.dll plugin/addons/tiltfive/bin/windows/x86_64/
cp gdtiltfive.android/build/bin/android/arm64/*.so plugin/addons/tiltfive/bin/android/arm64/
cp source/extension/TiltFiveNDK/lib/android/arm64-v8a/*.so plugin/addons/tiltfive/bin/android/arm64/
cp gdtiltfive.android/androidplugin/plugin/build/outputs/aar/gdtiltfive-debug.aar plugin/addons/tiltfive/bin/android
cp gdtiltfive.android/androidplugin/plugin/build/outputs/aar/gdtiltfive-release.aar plugin/addons/tiltfive/bin/android
- name: Copy files to destination for csharp
run: |
mkdir plugin_cs
mkdir plugin_cs/addons
cp -r source/example.csharp/addons/tiltfive plugin_cs/addons
cp source/LICENSE.txt plugin_cs/addons/tiltfive
cp source/CONTRIBUTORS.md plugin_cs/addons/tiltfive
cp source/CHANGES.md plugin_cs/addons/tiltfive
mkdir plugin_cs/addons/tiltfive/bin
mkdir plugin_cs/addons/tiltfive/bin/linux
mkdir plugin_cs/addons/tiltfive/bin/linux/x86_64
mkdir plugin_cs/addons/tiltfive/bin/windows
mkdir plugin_cs/addons/tiltfive/bin/windows/x86_64
mkdir plugin_cs/addons/tiltfive/bin/android/
mkdir plugin_cs/addons/tiltfive/bin/android/arm64
cp gdtiltfive.linux/build/bin/linux/x86_64/*.so plugin_cs/addons/tiltfive/bin/linux/x86_64/
cp gdtiltfive.linux/extension/TiltFiveNDK/lib/linux/x86_64/*.so plugin_cs/addons/tiltfive/bin/linux/x86_64/
cp gdtiltfive.windows/build/bin/windows/x86_64/*.dll plugin_cs/addons/tiltfive/bin/windows/x86_64/
cp gdtiltfive.windows/extension/TiltFiveNDK/lib/win/x86_64/*.dll plugin_cs/addons/tiltfive/bin/windows/x86_64/
cp gdtiltfive.android/build/bin/android/arm64/*.so plugin_cs/addons/tiltfive/bin/android/arm64/
cp source/extension/TiltFiveNDK/lib/android/arm64-v8a/*.so plugin_cs/addons/tiltfive/bin/android/arm64/
cp gdtiltfive.android/androidplugin/plugin/build/outputs/aar/gdtiltfive-debug.aar plugin_cs/addons/tiltfive/bin/android
cp gdtiltfive.android/androidplugin/plugin/build/outputs/aar/gdtiltfive-release.aar plugin_cs/addons/tiltfive/bin/android
- name: Calculate GIT short ref
run: |
cd source
echo "GITHUB_SHA_SHORT=$(git rev-parse --short ${{ github.sha }})" >> $GITHUB_ENV
cd ..
if: github.ref == 'refs/heads/main'
- name: Get tag name
run: |
echo "GITHUB_SHA_SHORT=$(echo ${GITHUB_REF##*/})" >> $GITHUB_ENV
if: startsWith(github.ref, 'refs/tags')
- name: Clean up extracted files
run: |
# rm -rf gdtiltfive.linux
rm -rf gdtiltfive.windows
# rm -rf gdtiltfive.android
# rm -rf gdtiltfive.macos
# rm -rf gdtiltfive.ios
rm -rf source
rm -rf .git
mv plugin gdtiltfive_${{ env.GITHUB_SHA_SHORT }}
mv plugin_cs gdtiltfive_cs_${{ env.GITHUB_SHA_SHORT }}
- name: Zip asset
run: |
zip -qq -r gdtiltfive_gdscript.zip gdtiltfive_${{ env.GITHUB_SHA_SHORT }}
zip -qq -r gdtiltfive_csharp.zip gdtiltfive_cs_${{ env.GITHUB_SHA_SHORT }}
- name: Create and upload asset
uses: ncipollo/release-action@v1
with:
allowUpdates: true
artifacts: "gdtiltfive_gdscript.zip, gdtiltfive_csharp.zip"
omitNameDuringUpdate: true
omitBodyDuringUpdate: true
omitPrereleaseDuringUpdate : true
token: ${{ secrets.GITHUB_TOKEN }}
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags')