Skip to content

Build for ARM too #8

Build for ARM too

Build for ARM too #8

Workflow file for this run

# ----------------------------------------------------------------------------
# GitHub Actions workflow to build the library and examples.
#
# See docs:
# - https://castle-engine.io/github_actions
# - https://docs.github.com/en/actions
# ----------------------------------------------------------------------------
name: Build
on:
pull_request:
push:
repository_dispatch:
types: [cge-docker-unstable-changed]
defaults:
run:
shell: bash
jobs:
# Make builds on "native" (not in some virtual environment visible to us) runners.
build-native:
name: Build (Native)
strategy:
matrix:
runner: [
ubuntu-latest,
windows-latest,
# last Intel-based macOS
macos-12
]
include:
- runner: ubuntu-latest
library_extension: so
- runner: windows-latest
library_extension: dll
- runner: macos-12
library_extension: dylib
runs-on: ${{ matrix.runner }}
steps:
- uses: actions/checkout@v4
with:
repository: castle-engine/castle-engine
- name: Install FPC+Lazarus
uses: gcarreno/setup-lazarus@v3.3.1
with:
lazarus-version: stable
# - name: Install Linux dependencies
# if: ${{ matrix.runner == 'ubuntu-latest' }}
# run: |
# sudo apt-get update
# sudo apt-get --no-install-recommends -y install libgl-dev
# Build Castle Game Engine and set related environment variables.
- name: Castle Game Engine - Env CASTLE_ENGINE_PATH
run: echo "CASTLE_ENGINE_PATH=$GITHUB_WORKSPACE" >> $GITHUB_ENV
- name: Castle Game Engine - Env PATH (Windows)
if: ${{ matrix.runner == 'windows-latest' }}
run: echo "PATH=${PATH}:`cygpath --unix ${CASTLE_ENGINE_PATH}/tools/build-tool/`" >> $GITHUB_ENV
- name: Castle Game Engine - Env PATH (non-Windows)
if: ${{ matrix.runner != 'windows-latest' }}
run: echo "PATH=$PATH:$CASTLE_ENGINE_PATH/tools/build-tool/" >> $GITHUB_ENV
- name: Castle Game Engine - Build
run: cd $CASTLE_ENGINE_PATH/tools/build-tool/ && ./castle-engine_compile.sh
- name: Set environment FPC_OS
run: echo "FPC_OS="`fpc -iTO` >> $GITHUB_ENV
- name: Set environment FPC_CPU
run: echo "FPC_CPU="`fpc -iTP` >> $GITHUB_ENV
- name: Build
run: |
cd src/deprecated_library/
./castleengine_compile.sh
ZIP_NAME=castle-library-model-viewer_-${FPC_OS}-${FPC_CPU}.zip
zip -r ${ZIP_NAME} *.${{ matrix.library_extension }}"
mv ${ZIP_NAME} ../../
- name: Archive Artifacts
uses: actions/upload-artifact@v4
with:
name: build-native-${{ matrix.runner }}
path: "*.zip"
if-no-files-found: error
# Make builds on Docker runners.
build-using-docker:
name: Build (Using Docker)
runs-on: ubuntu-latest
container: kambi/castle-engine-cloud-builds-tools:cge-unstable
steps:
# Although CGE is already available in the container,
# check it out again, to be prepared for future when library code
# will move to this repo (castle-engine/castle-library-model-viewer).
- uses: actions/checkout@v4
with:
repository: castle-engine/castle-engine
- name: Build Win32
run: |
cd src/deprecated_library/
TARGET_OS=win32
TARGET_CPU=i386
castle-engine compile --verbose --os=$TARGET_OS --cpu=$TARGET_CPU
ZIP_NAME=castle-library-model-viewer_-${TARGET_OS}-${TARGET_CPU}.zip
zip -r ${ZIP_NAME} *.dll"
mv ${ZIP_NAME} ../../
- name: Archive Artifacts
uses: actions/upload-artifact@v4
with:
name: build-docker-win32
path: "*.zip"
if-no-files-found: error
build-arm-runner:
name: Build (ARM Runner)
runs-on: ubuntu-latest
strategy:
matrix:
arch: [armv7l, aarch64]
include:
# Raspberry Pi 32-bit (Arm), bullseye (older version, used on Raspberry Pi 4 by default)
- arch: armv7l
cpu: cortex-a7
base_image: dietpi:rpi_armv7_bullseye
cpu_info: cpuinfo/raspberrypi_3b
# Raspberry Pi 64-bit (Aarch64), latest (bookworm)
- arch: aarch64
cpu: cortex-a53
base_image: raspios_lite_arm64:latest
cpu_info: cpuinfo/raspberrypi_zero2_w_arm64_w
steps:
- uses: actions/checkout@v4
with:
repository: castle-engine/castle-engine
- uses: pguyot/arm-runner-action@v2
with:
base_image: ${{ matrix.base_image }}
cpu: ${{ matrix.cpu }}
shell: /bin/bash -eo pipefail
image_additional_mb: 6000
# Avoids the need for copy_artifact_path later.
bind_mount_repository: true
commands: |
# Useful string to grep logs, because log of script execution is somewhat buried in the middle of pguyot/arm-runner-action log
echo 'CGE script starts here'
# Show system info
uname -a
# Install FPC and other Linux dependencies
sudo apt-get update
sudo apt-get --no-install-recommends -y install libgl-dev fpc git git-lfs zip
# Set environment
ARM_RUNNER_WORKSPACE=`pwd`
export CASTLE_ENGINE_PATH=$ARM_RUNNER_WORKSPACE
export "PATH=${PATH}:/cge-work/installed/bin/"
FPC_OS=`fpc -iTO`
FPC_CPU=`fpc -iTP`
# Build CGE Tools
mkdir -p /cge-work/
cd "${CASTLE_ENGINE_PATH}"
rm -Rf /cge-work/installed/
mkdir -p /cge-work/installed/
make clean tools install PREFIX=/cge-work/installed/
# Build and Pack Library
cd "${CASTLE_ENGINE_PATH}/src/deprecated_library/"
castle-engine compile --verbose --os=${FPC_OS} --cpu=${FPC_CPU}
ZIP_NAME=castle-library-model-viewer_-${FPC_OS}-${FPC_CPU}.zip
zip -r ${ZIP_NAME} *.so
mv ${ZIP_NAME} ../../
- name: Archive Artifacts
uses: actions/upload-artifact@v4
with:
name: build-raspberry-pi-${{ matrix.arch }}
path: "*.zip"
if-no-files-found: error
release:
name: Release
runs-on: ubuntu-latest
needs: [build-native, build-using-docker, build-arm-runner]
steps:
- name: Download packaged releases
uses: actions/download-artifact@v4
with:
merge-multiple: true
- name: List downloaded files
run: ls -R
- name: GH CLI status
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: gh auth status
# Releases files in the "snapshot" release.
- name: Release Artifacts
if: ${{ github.ref == 'refs/heads/master' }}
run: gh release --repo ${{ github.repository }} upload snapshot --clobber *.zip *.tar.gz *.apk
env:
GH_TOKEN: ${{ github.token }}
update-release-tag:
name: Update Release Tag (make snapshot tag point to the build commit on master branch)
runs-on: ubuntu-latest
needs: [release]
steps:
- uses: actions/checkout@v4
- name: Update Release Tag
if: ${{ github.ref == 'refs/heads/master' }}
run: |
# --force allows to overwrite previous tag
git tag --force snapshot
# --force allows to push with overwritten tag
git push --force origin snapshot