|
| 1 | +# ---------------------------------------------------------------------------- |
| 2 | +# GitHub Actions workflow to build this application. |
| 3 | +# Using latest Castle Game Engine ( https://castle-engine.io/ ) snapshot. |
| 4 | +# For multiple platforms (Linux, Windows). |
| 5 | +# |
| 6 | +# This uses GitHub-hosted runners, that is: you don't need to set up any server |
| 7 | +# infrastructure, GitHub provides it all for free for open-source projects. |
| 8 | +# |
| 9 | +# See docs: |
| 10 | +# - https://castle-engine.io/github_actions |
| 11 | +# - https://docs.github.com/en/actions |
| 12 | +# ---------------------------------------------------------------------------- |
| 13 | + |
| 14 | +name: Build |
| 15 | + |
| 16 | +on: |
| 17 | + pull_request: |
| 18 | + # Run on push to any branch, not on tags. |
| 19 | + # Checking tags is not useful for us (we check the commit when it happened |
| 20 | + # at branch) and we would waste 2x time to update on every "snapshpt" tag change. |
| 21 | + push: |
| 22 | + branches: |
| 23 | + - '**' |
| 24 | + |
| 25 | +jobs: |
| 26 | + # Build for platforms supported by |
| 27 | + # CGE Docker image https://hub.docker.com/r/kambi/castle-engine-cloud-builds-tools/ . |
| 28 | + build-using-docker: |
| 29 | + name: Build Using Docker |
| 30 | + runs-on: ubuntu-latest |
| 31 | + container: kambi/castle-engine-cloud-builds-tools:cge-unstable |
| 32 | + steps: |
| 33 | + - uses: actions/checkout@v4 |
| 34 | + |
| 35 | + - name: Package Windows |
| 36 | + run: castle-engine package --os=win64 --cpu=x86_64 --verbose |
| 37 | + - name: Archive Artifacts |
| 38 | + uses: actions/upload-artifact@v4 |
| 39 | + with: |
| 40 | + name: windows-build |
| 41 | + path: "*-win64-x86_64.zip" |
| 42 | + if-no-files-found: error |
| 43 | + |
| 44 | + - name: Package Linux |
| 45 | + run: castle-engine package --os=linux --cpu=x86_64 --verbose |
| 46 | + - name: Archive Artifacts |
| 47 | + uses: actions/upload-artifact@v4 |
| 48 | + with: |
| 49 | + name: linux-build |
| 50 | + path: "*-linux-x86_64.tar.gz" |
| 51 | + if-no-files-found: error |
| 52 | + |
| 53 | + - name: Unpack Android Secrets |
| 54 | + env: |
| 55 | + ANDROID_KEYSTORE: ${{ secrets.ANDROID_KEYSTORE }} |
| 56 | + ANDROID_SIGNING_PROPERTIES: ${{ secrets.ANDROID_SIGNING_PROPERTIES }} |
| 57 | + run: | |
| 58 | + echo "$ANDROID_KEYSTORE" | base64 --decode > cge.keystore |
| 59 | + echo "$ANDROID_SIGNING_PROPERTIES" | sed -e "s|WORKSPACE|${GITHUB_WORKSPACE}|" - > AndroidSigningProperties.txt |
| 60 | + - name: Package Android |
| 61 | + run: castle-engine package --target=android --verbose |
| 62 | + - name: Archive Artifacts |
| 63 | + uses: actions/upload-artifact@v4 |
| 64 | + with: |
| 65 | + name: android-build |
| 66 | + path: "*.apk" |
| 67 | + if-no-files-found: error |
| 68 | + |
| 69 | + # Build for platforms supported from macOS. |
| 70 | + build-macos: |
| 71 | + name: Build Using macOS |
| 72 | + runs-on: macos-latest |
| 73 | + steps: |
| 74 | + - uses: actions/checkout@v4 |
| 75 | + - name: Install FPC+Lazarus |
| 76 | + uses: gcarreno/setup-lazarus@v3.2.17 |
| 77 | + with: |
| 78 | + lazarus-version: stable |
| 79 | + - name: Castle Game Engine - Env CASTLE_ENGINE_PATH |
| 80 | + run: echo "CASTLE_ENGINE_PATH=$GITHUB_WORKSPACE/castle-engine" >> $GITHUB_ENV |
| 81 | + - name: Castle Game Engine - Env PATH (non-Windows) |
| 82 | + run: echo "PATH=$PATH:$CASTLE_ENGINE_PATH/tools/build-tool/" >> $GITHUB_ENV |
| 83 | + - name: Castle Game Engine - Clone snapshot |
| 84 | + run: git clone --depth 1 --single-branch --branch snapshot https://github.com/castle-engine/castle-engine/ |
| 85 | + - name: Castle Game Engine - Build |
| 86 | + run: cd $CASTLE_ENGINE_PATH/tools/build-tool/ && ./castle-engine_compile.sh |
| 87 | + |
| 88 | + - name: Package macOS |
| 89 | + run: castle-engine package --os=darwin --cpu=x86_64 --verbose |
| 90 | + - name: Archive Artifacts |
| 91 | + uses: actions/upload-artifact@v4 |
| 92 | + with: |
| 93 | + name: macos-build |
| 94 | + path: "*-darwin-x86_64.zip" |
| 95 | + if-no-files-found: error |
| 96 | + |
| 97 | + release: |
| 98 | + name: Release |
| 99 | + runs-on: ubuntu-latest |
| 100 | + # Only upload release if all builds, on all runners, succeeded. |
| 101 | + needs: [build-using-docker, build-macos] |
| 102 | + steps: |
| 103 | + - name: Download packaged releases |
| 104 | + uses: actions/download-artifact@v4 |
| 105 | + with: |
| 106 | + merge-multiple: true |
| 107 | + - name: List downloaded files |
| 108 | + run: ls -R |
| 109 | + - name: GH CLI status |
| 110 | + env: |
| 111 | + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 112 | + run: gh auth status |
| 113 | + # Releases files in the "snapshot" release. |
| 114 | + - name: Release Artifacts |
| 115 | + if: ${{ github.ref == 'refs/heads/master' }} |
| 116 | + run: gh release --repo ${{ github.repository }} upload snapshot --clobber *.zip *.tar.gz *.apk |
| 117 | + env: |
| 118 | + GH_TOKEN: ${{ github.token }} |
| 119 | + |
| 120 | + update-release-tag: |
| 121 | + name: Update Release Tag (make snapshot tag point to the build commit on master branch) |
| 122 | + runs-on: ubuntu-latest |
| 123 | + needs: [release] |
| 124 | + steps: |
| 125 | + - uses: actions/checkout@v4 |
| 126 | + - name: Update Release Tag |
| 127 | + if: ${{ github.ref == 'refs/heads/master' }} |
| 128 | + run: | |
| 129 | + # --force allows to overwrite previous tag |
| 130 | + git tag --force snapshot |
| 131 | + # --force allows to push with overwritten tag |
| 132 | + git push --force origin snapshot |
0 commit comments