# ---------------------------------------------------------------------------- # GitHub Actions workflow to build this application. # Using latest Castle Game Engine ( https://castle-engine.io/ ) snapshot. # For multiple platforms (Linux, Windows, macOS, Android). # # This uses GitHub-hosted runners, that is: you don't need to set up any server # infrastructure, GitHub provides it all for free for open-source projects. # # See docs: # - https://castle-engine.io/github_actions # - https://docs.github.com/en/actions # ---------------------------------------------------------------------------- name: Build on: pull_request: # Run on push to any branch, not on tags. # Checking tags is not useful for us (we check the commit when it happened # at branch) and we would waste 2x time to update on every "snapshpt" tag change. push: branches: - '**' repository_dispatch: types: [cge-docker-unstable-changed] 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 for platforms supported by # CGE Docker image https://hub.docker.com/r/kambi/castle-engine-cloud-builds-tools/ . # # Since setting up Docker image takes majority of time (5-6 mins) # compared to actually getting and compiling CGE (1 min) # and building application (~1 min for each platform), # we build all platforms possible within one job. build-using-docker: name: Build Using Docker runs-on: ubuntu-latest container: kambi/castle-engine-cloud-builds-tools:cge-unstable steps: - uses: actions/checkout@v6 # Here we use "cge-unstable" Docker image, that already contains # FPC and Castle Game Engine sources and tools. # Alternative would be to setup FPC and CGE using # https://github.com/castle-engine/castle-build-ci/ script, # see macOS job for example. - name: Package Windows run: castle-engine package --os=win64 --cpu=x86_64 --verbose - name: Archive Artifacts # See https://github.com/actions/upload-artifact uses: actions/upload-artifact@v6 with: name: windows-build # Note: Keep paths that start with asterisk in double qoutes, to avoid misinterpreting as YAML reference. # See https://stackoverflow.com/questions/19109912/yaml-do-i-need-quotes-for-strings-in-yaml # https://yamlchecker.com/ path: "*-win64-x86_64.zip" if-no-files-found: error - name: Package Linux run: castle-engine package --os=linux --cpu=x86_64 --verbose - name: Archive Artifacts uses: actions/upload-artifact@v6 with: name: linux-build path: "*-linux-x86_64.tar.gz" if-no-files-found: error - name: Unpack Android Secrets env: ANDROID_KEYSTORE: ${{ secrets.ANDROID_KEYSTORE }} ANDROID_SIGNING_PROPERTIES: ${{ secrets.ANDROID_SIGNING_PROPERTIES }} run: | echo "$ANDROID_KEYSTORE" | base64 --decode > cge.keystore echo "$ANDROID_SIGNING_PROPERTIES" | sed -e "s|WORKSPACE|${GITHUB_WORKSPACE}|" - > AndroidSigningProperties.txt - name: Package Android run: castle-engine package --target=android --verbose - name: Archive Artifacts uses: actions/upload-artifact@v6 with: name: android-build path: "*.apk" if-no-files-found: error # Build for platforms supported from macOS. # This means to build for macOS and (maybe in the future) iOS. build-macos: name: Build Using macOS strategy: matrix: runner: [ macos-15-intel, macos-latest ] runs-on: ${{ matrix.runner }} steps: - name: Checkout application uses: actions/checkout@v6 - name: Setup FPC and CGE run: | cd /tmp/ # temporary directory, to be separate from the current project files git clone https://github.com/castle-engine/castle-build-ci.git \ --depth=1 --single-branch --branch=master castle-build-ci/install_dependencies castle-build-ci/setup_castle_engine - name: Package to Bundle (macOS) if: ${{ runner.os == 'macOS' }} run: castle-engine package --package-format=mac-app-bundle - name: Sign and Notarize (macOS) if: ${{ runner.os == 'macOS' }} env: # for codesigning APPLE_IDENTITY: ${{ vars.APPLE_IDENTITY }} APPLE_BUILD_CERTIFICATE_BASE64: ${{ secrets.APPLE_BUILD_CERTIFICATE_BASE64 }} APPLE_P12_PASSWORD: ${{ secrets.APPLE_P12_PASSWORD }} APPLE_KEYCHAIN_PASSWORD: ${{ secrets.APPLE_KEYCHAIN_PASSWORD }} # for notarization APPLE_ID: ${{ vars.APPLE_ID }} APPLE_TEAM_ID: ${{ vars.APPLE_TEAM_ID }} APPLE_APP_PASSWORD: ${{ secrets.APPLE_APP_PASSWORD }} run: | /tmp/castle-build-ci/apple/setup_signing /tmp/castle-build-ci/apple/sign_notarize_bundle \ "`castle-engine output caption`.app" \ "`castle-engine output executable-name`" - name: Package to Zip (macOS) if: ${{ runner.os == 'macOS' }} run: | zip -r "`castle-engine output package-name`" "`castle-engine output caption`.app/" - name: Archive Artifacts uses: actions/upload-artifact@v6 with: name: macos-build-${{ matrix.runner }} path: "*-darwin-*.zip" if-no-files-found: error release: name: Release runs-on: ubuntu-latest # Only upload release if all builds, on all runners, succeeded. needs: [build-using-docker, build-macos] steps: - name: Download packaged releases uses: actions/download-artifact@v7 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 release. - name: Release Artifacts if: ${{ github.ref == 'refs/heads/master' }} run: gh release --repo ${{ github.repository }} upload ${{ env.release_tag }} --clobber *.zip *.tar.gz *.apk 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@v6 - 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 }}