cge-docker-unstable-changed #190
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. | |
# Details: | |
# - Builds and packages: creates release packages (zip,tar.gz) | |
# for all interesting platforms. | |
# Some of them use our self-hosted runners, some use Docker on GH-hosted runners. | |
# - Uploads the release packages as GitHub release of "snapshot" tag, | |
# https://github.com/castle-engine/castle-model-viewer/releases/tag/snapshot | |
# - Updates the "snapshot" tag to point to the build commit. | |
# ---------------------------------------------------------------------------- | |
name: Build | |
on: | |
push: | |
pull_request: | |
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 | |
# Which Castle Game Engine tag/branch to use for building. | |
# This *should* be "snapshot", which is our latest CGE that passed automatic tests. | |
# But for quick hotfix in exceptional situation, you may want to use "master" | |
# or any other branch/tag. | |
engine_tag: snapshot | |
defaults: | |
run: | |
shell: bash | |
jobs: | |
build_docker: | |
name: Build From Docker | |
runs-on: ubuntu-latest | |
# We could use a Docker container with cge-unstable, so it already contains | |
# CGE (with build tool) set up. This way we know we only use CGE that | |
# passed automatic tests, we have castle-engine on the PATH, and things are easy. | |
# | |
# Later: But to make engine_tag configurable, we instead get CGE from GitHub. | |
#container: kambi/castle-engine-cloud-builds-tools:cge-unstable | |
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 PATH (non-Windows) | |
run: echo "PATH=$PATH:$CASTLE_ENGINE_PATH/tools/build-tool/" >> $GITHUB_ENV | |
- name: Castle Game Engine - Clone ${{ env.engine_tag }} | |
run: git clone --depth 1 --single-branch --branch ${{ env.engine_tag }} 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: | |
# - castle-model-converter first, it will be packaged in castle-model-viewer CastleEngineManifest.xml | |
# - then build and package castle-model-viewer | |
- name: Package Windows / x86_64 | |
run: | | |
castle-engine compile --os=win64 --cpu=x86_64 --manifest-name=CastleEngineManifest.converter.xml | |
castle-engine package --os=win64 --cpu=x86_64 | |
- name: Package Windows / i386 | |
run: | | |
# We need "make clean" to be sure to remove previous build artifacts, e.g. castle-model-converter.exe | |
make clean | |
castle-engine compile --os=win32 --cpu=i386 --manifest-name=CastleEngineManifest.converter.xml | |
castle-engine package --os=win32 --cpu=i386 | |
- name: Package Linux / x86_64 | |
run: | | |
# We need "make clean" to be sure to remove previous build artifacts, e.g. castle-model-converter.exe | |
make clean | |
castle-engine compile --os=linux --cpu=x86_64 --manifest-name=CastleEngineManifest.converter.xml | |
castle-engine 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, 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 PATH (non-Windows) | |
run: echo "PATH=$PATH:$CASTLE_ENGINE_PATH/tools/build-tool/" >> $GITHUB_ENV | |
- name: Castle Game Engine - Clone ${{ env.engine_tag }} | |
run: git clone --depth 1 --single-branch --branch ${{ env.engine_tag }} 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 (non macOS) | |
if: ${{ matrix.runner != 'macos_x64' }} | |
run: | | |
castle-engine compile --manifest-name=CastleEngineManifest.converter.xml | |
castle-engine package | |
- name: Package (macOS) | |
if: ${{ matrix.runner == 'macos_x64' }} | |
# Special order for macOS: | |
# - First compile and package castle-model-viewer, it will be a bundle. | |
# - Add 2nd exe "castle-model-converter" to the bundle. | |
# - zip it manually | |
# (TODO: we could add file to zip created by initial "package" instead?) | |
run: | | |
castle-engine compile --manifest-name=CastleEngineManifest.converter.xml | |
castle-engine package --package-format=mac-app-bundle | |
cp castle-model-converter castle-model-viewer.app/Contents/MacOS/ | |
VERSION=`castle-engine output version` | |
ZIPNAME=castle-model-viewer-"${VERSION}"-darwin-x86_64.zip | |
zip -r "${ZIPNAME}" castle-model-viewer.app/ | |
echo "Packed to ${ZIPNAME}" | |
- name: Archive Artifacts | |
uses: actions/upload-artifact@v4 | |
with: | |
name: ${{ matrix.runner }}-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] | |
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 }} |