GitLab CI/CD

1. Introduction

GitLab CI

You can use GitLab CI/CD to automatically build your project, if you commit it to GitLab. You can use the provided for free GitLab-hosted runners or set up your own runner.

2. Example project

We host test-gitlab-ci project on GitLab specifically for the purpose of demonstrating this feature. You can open CI/CD → Pipelines to see the jobs it executed, their status, download their artifacts etc.

Note
You don’t need to be logged into GitLab to see the build results.

3. Usage

  1. Download this file: .gitlab-ci.yml and place it in the top-level directory of your repository.

    Note
    The .gitlab-ci.yml filename starts with a dot, this means it is a hidden file (by convention) on Unix.
  2. Commit and push it, and watch the "CI/CD" subsection of your project get populated with "Pipelines" and "Jobs". You can download the artifacts for each job.

    By default, these are builds for Linux and Windows.

4. How to get FPC and CGE inside the CI job

  • You can use Castle Game Engine Docker image.

    The Docker image provides ready FPC with some cross-compilers e.g. to Android.

    On the other hand, it cannot build for macOS.

    It also requires a considerable disk space. The disk space on free GitLab-hosted runners seems too small to unpack it.

    But if you use your own runners, disk space may not be a problem. If you want you can change the YAML file to use Docker images (to have more power and build easily e.g. also for Android). Simply uncomment the section in that file marked as # Commented out version using Docker image.

  • castle-build-ci scripts.

    This gets our recommended FPC version and then downloads CGE.

  • Other approaches are also possible.

    • You could install FPC using apt-get install fpc on Linux (and equivalent on other platforms, e.g. brew install fpc on macOS, choco install lazarus on Windows to get Lazarus from Chocolatey).

      Make sure that the runner packages have recent enough FPC version, see supported FPC versions.

    • You could download our FPC builds directly.

    • You can get CGE by just git clone of our repository and compiling our build tool from source using ./castle-engine_compile.sh. You can essentially follow a super-minimal version of compiling from source docs to do that, you only need to compile the build tool, which can then build your project. Our scripts in castle-build-ci can be used as a reference, they do exactly that — but it’s not that hard to do it yourself from scratch :)


To improve this documentation just edit this page and create a pull request to cge-www repository.