From d8f98f673d41474baef3411e43b7b8a20afa8bd0 Mon Sep 17 00:00:00 2001 From: Michalis Kamburelis Date: Wed, 8 May 2024 03:50:40 +0200 Subject: [PATCH] Build using GitHub Actions, upload to "snapshot" release --- .github/FUNDING.yml | 12 ++++ .github/dependabot.yml | 10 ++++ .github/workflows/build.yml | 116 ++++++++++++++++++++++++++++++++++++ 3 files changed, 138 insertions(+) create mode 100644 .github/FUNDING.yml create mode 100644 .github/dependabot.yml create mode 100644 .github/workflows/build.yml diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml new file mode 100644 index 0000000..d7f5a04 --- /dev/null +++ b/.github/FUNDING.yml @@ -0,0 +1,12 @@ +# These are supported funding model platforms + +github: [castle-engine, michaliskambi] # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2] +patreon: castleengine # Replace with a single Patreon username +open_collective: castle-engine # Replace with a single Open Collective username +# ko_fi: # Replace with a single Ko-fi username +# tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel +# community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry +# liberapay: # Replace with a single Liberapay username +# issuehunt: # Replace with a single IssueHunt username +# otechie: # Replace with a single Otechie username +# custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2'] diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..b2e40e3 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,10 @@ +# Check that GitHub Actions use latest versions of plugins. +# See https://docs.github.com/en/code-security/dependabot/working-with-dependabot/keeping-your-actions-up-to-date-with-dependabot . + +version: 2 +updates: + # Maintain dependencies for GitHub Actions + - package-ecosystem: "github-actions" + directory: "/" + schedule: + interval: "weekly" diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..68e0c88 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,116 @@ +# ---------------------------------------------------------------------------- +# GitHub Actions workflow to build and package the project using Castle Game Engine. +# ---------------------------------------------------------------------------- + +name: Build + +on: [push, pull_request] + +defaults: + run: + shell: bash + +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: + # - 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: | + ${BUILD_TOOL} compile --os=win64 --cpu=x86_64 --manifest-name=CastleEngineManifest.converter.xml + ${BUILD_TOOL} package --os=win64 --cpu=x86_64 + - name: Package Windows / i386 + run: | + ${BUILD_TOOL} compile --os=win32 --cpu=i386 --manifest-name=CastleEngineManifest.converter.xml + ${BUILD_TOOL} package --os=win32 --cpu=i386 + - name: Package Linux / x86_64 + run: | + ${BUILD_TOOL} compile --os=linux --cpu=x86_64 --manifest-name=CastleEngineManifest.converter.xml + ${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 + # Releases files in the "snapshot" release. + - name: Release Artifacts + if: ${{ github.ref == 'refs/heads/master' }} + run: gh release --repo castle-engine/castle-model-viewer upload snapshot --clobber *.zip *.tar.gz + env: + GH_TOKEN: ${{ github.token }} + + 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 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 (non macOS) + if: ${{ matrix.runner != 'macos_x64' }} + run: | + ${BUILD_TOOL} compile --manifest-name=CastleEngineManifest.converter.xml + ${BUILD_TOOL} 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: | + ${BUILD_TOOL} compile --manifest-name=CastleEngineManifest.converter.xml + ${BUILD_TOOL} 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 + # Releases files in the "snapshot" release. + - name: Release Artifacts + if: ${{ github.ref == 'refs/heads/master' }} + run: gh release --repo castle-engine/castle-model-viewer upload snapshot --clobber *.zip *.tar.gz + env: + GH_TOKEN: ${{ github.token }}