cge-docker-unstable-changed #184
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
# ---------------------------------------------------------------------------- | |
# GitHub Actions workflow to build and package the project using Castle Game Engine. | |
# ---------------------------------------------------------------------------- | |
name: Build | |
on: | |
push: | |
pull_request: | |
repository_dispatch: | |
types: [cge-docker-unstable-changed] | |
defaults: | |
run: | |
shell: bash | |
env: | |
# To which GitHub release tag should we upload artifacts. | |
# Can be "snapshot" or "vX.Y.Z" (latter when we make stable release). | |
release_tag: snapshot | |
#release_tag: vX.Y.Z | |
jobs: | |
build_docker: | |
name: Build From Docker | |
runs-on: ubuntu-latest | |
container: kambi/castle-engine-cloud-builds-tools:cge-none | |
steps: | |
- uses: actions/checkout@v4 | |
# Setup Castle Game Engine | |
- name: Castle Game Engine - Env CASTLE_ENGINE_PATH | |
run: echo "CASTLE_ENGINE_PATH=$GITHUB_WORKSPACE/castle-engine" >> $GITHUB_ENV | |
- name: Castle Game Engine - Env BUILD_TOOL | |
run: echo "BUILD_TOOL=$CASTLE_ENGINE_PATH/tools/build-tool/castle-engine" >> $GITHUB_ENV | |
- name: Castle Game Engine - Clone snapshot | |
run: git clone --depth 1 --single-branch --branch snapshot https://github.com/castle-engine/castle-engine/ | |
- name: Castle Game Engine - Build | |
run: cd $CASTLE_ENGINE_PATH/tools/build-tool/ && ./castle-engine_compile.sh | |
# Package application | |
- name: Package Windows / x86_64 | |
run: ${BUILD_TOOL} package --os=win64 --cpu=x86_64 | |
- name: Package Windows / i386 | |
run: ${BUILD_TOOL} package --os=win32 --cpu=i386 | |
- name: Package Linux / x86_64 | |
run: ${BUILD_TOOL} package --os=linux --cpu=x86_64 | |
- name: Archive Artifacts | |
uses: actions/upload-artifact@v4 | |
with: | |
name: windows-linux-builds | |
path: | | |
*.zip | |
*.tar.gz | |
#if-no-files-found: error | |
build_runner_native: | |
name: Build on Native Runner (target OS/CPU = source OS/CPU) | |
strategy: | |
matrix: | |
runner: [ | |
macos_x64 | |
# We use arm-runner for Raspberry Pi builds now, to not have costs of maintaining our own runners. | |
#raspberry_pi_64, | |
#raspberry_pi_32 | |
] | |
runs-on: ${{ matrix.runner }} | |
steps: | |
- uses: actions/checkout@v4 | |
# Setup Castle Game Engine | |
- name: Castle Game Engine - Env CASTLE_ENGINE_PATH | |
run: echo "CASTLE_ENGINE_PATH=$GITHUB_WORKSPACE/castle-engine" >> $GITHUB_ENV | |
- name: Castle Game Engine - Env BUILD_TOOL | |
run: echo "BUILD_TOOL=$CASTLE_ENGINE_PATH/tools/build-tool/castle-engine" >> $GITHUB_ENV | |
- name: Castle Game Engine - Clone snapshot | |
run: git clone --depth 1 --single-branch --branch snapshot https://github.com/castle-engine/castle-engine/ | |
- name: Castle Game Engine - Build | |
run: cd $CASTLE_ENGINE_PATH/tools/build-tool/ && ./castle-engine_compile.sh | |
# Package application | |
- name: Package | |
run: ${BUILD_TOOL} package | |
- name: Archive Artifacts | |
uses: actions/upload-artifact@v4 | |
with: | |
name: ${{ matrix.runner }}-build | |
path: | | |
*.zip | |
*.tar.gz | |
#if-no-files-found: error | |
build_arm_runner: | |
name: Build on ARM Runner (for Raspberry Pi) | |
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 | |
# Raspberry Pi 64-bit (Aarch64), latest (bookworm) | |
- arch: aarch64 | |
cpu: cortex-a53 | |
base_image: raspios_lite_arm64:latest | |
steps: | |
- uses: actions/checkout@v4 | |
- 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 make unzip sed zip | |
# Check versions (and availability) of our requirements early | |
fpc -iV | |
make --version | |
sed --version | |
# Setup Castle Game Engine | |
ARM_RUNNER_WORKSPACE=`pwd` | |
export "CASTLE_ENGINE_PATH=$ARM_RUNNER_WORKSPACE/castle-engine" | |
export "PATH=$PATH:$CASTLE_ENGINE_PATH/tools/build-tool/" | |
git clone --depth 1 --single-branch --branch snapshot https://github.com/castle-engine/castle-engine/ | |
cd $CASTLE_ENGINE_PATH/tools/build-tool/ | |
./castle-engine_compile.sh | |
cd $ARM_RUNNER_WORKSPACE | |
# Package application | |
castle-engine package | |
- name: Archive Artifacts | |
uses: actions/upload-artifact@v4 | |
with: | |
name: raspberry-pi-${{ matrix.arch }}-build | |
path: | | |
*.zip | |
*.tar.gz | |
#if-no-files-found: error | |
release: | |
name: Release | |
runs-on: ubuntu-latest | |
# Only upload release if all builds, on all runners, succeeded. | |
needs: [build_docker, build_runner_native, 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 GitHub release. | |
- name: Release Artifacts | |
if: ${{ github.ref == 'refs/heads/master' }} | |
run: gh release --repo ${{ github.repository }} upload ${{ env.release_tag }} --clobber *.zip *.tar.gz | |
env: | |
GH_TOKEN: ${{ github.token }} | |
update-release-tag: | |
name: Update Release Tag (make release 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 ${{ env.release_tag }} | |
# --force allows to push with overwritten tag | |
git push --force origin ${{ env.release_tag }} |