Debian Codegraph @

.github/workflows/build.yml

raw
1 # ----------------------------------------------------------------------------
2 # GitHub Actions workflow to build and package the project using Castle Game Engine.
3 # Details:
4 # - Builds and packages: creates release packages (zip,tar.gz)
5 # for all interesting platforms.
6 # Some of them use our self-hosted runners, some use Docker on GH-hosted runners.
7 # - Uploads the release packages as GitHub release of "snapshot" tag,
8 # https://github.com/castle-engine/castle-model-viewer/releases/tag/snapshot
9 # - Updates the "snapshot" tag to point to the build commit.
10 # ----------------------------------------------------------------------------
11
12 name: Build
13
14 on:
15 push:
16 pull_request:
17 repository_dispatch:
18 types: [cge-docker-unstable-changed]
19
20 env:
21 # To which GitHub release tag should we upload artifacts.
22 # Can be "snapshot" or "vX.Y.Z" (latter when we make stable release).
23 #release_tag: snapshot
24 release_tag: v5.2.0
25
26 # Which Castle Game Engine tag/branch to use for building.
27 # This *should* be "snapshot", which is our latest CGE that passed automatic tests.
28 # But for quick hotfix in exceptional situation, you may want to use "master"
29 # or any other branch/tag.
30 engine_tag: snapshot
31
32 defaults:
33 run:
34 shell: bash
35
36 jobs:
37 build_docker:
38 name: Build From Docker
39 runs-on: ubuntu-latest
40
41 # We could use a Docker container with cge-unstable, so it already contains
42 # CGE (with build tool) set up. This way we know we only use CGE that
43 # passed automatic tests, we have castle-engine on the PATH, and things are easy.
44 #
45 # Later: But to make engine_tag configurable, we instead get CGE from GitHub.
46 #container: kambi/castle-engine-cloud-builds-tools:cge-unstable
47
48 container: kambi/castle-engine-cloud-builds-tools:cge-none
49 steps:
50 - uses: actions/checkout@v4
51
52 # Setup Castle Game Engine
53 - name: Castle Game Engine - Env CASTLE_ENGINE_PATH
54 run: echo "CASTLE_ENGINE_PATH=$GITHUB_WORKSPACE/castle-engine" >> $GITHUB_ENV
55 - name: Castle Game Engine - Env PATH (non-Windows)
56 run: echo "PATH=$PATH:$CASTLE_ENGINE_PATH/tools/build-tool/" >> $GITHUB_ENV
57 - name: Castle Game Engine - Clone ${{ env.engine_tag }}
58 run: git clone --depth 1 --single-branch --branch ${{ env.engine_tag }} https://github.com/castle-engine/castle-engine/
59 - name: Castle Game Engine - Build
60 run: cd $CASTLE_ENGINE_PATH/tools/build-tool/ && ./castle-engine_compile.sh
61
62 # Package application:
63 # - castle-model-converter first, it will be packaged in castle-model-viewer CastleEngineManifest.xml
64 # - then build and package castle-model-viewer
65 - name: Package Windows / x86_64
66 run: |
67 castle-engine compile --os=win64 --cpu=x86_64 --manifest-name=CastleEngineManifest.converter.xml
68 castle-engine package --os=win64 --cpu=x86_64
69 - name: Package Windows / i386
70 run: |
71 # We need "make clean" to be sure to remove previous build artifacts, e.g. castle-model-converter.exe
72 make clean
73 castle-engine compile --os=win32 --cpu=i386 --manifest-name=CastleEngineManifest.converter.xml
74 castle-engine package --os=win32 --cpu=i386
75 - name: Package Linux / x86_64
76 run: |
77 # We need "make clean" to be sure to remove previous build artifacts, e.g. castle-model-converter.exe
78 make clean
79 castle-engine compile --os=linux --cpu=x86_64 --manifest-name=CastleEngineManifest.converter.xml
80 castle-engine package --os=linux --cpu=x86_64
81 - name: Archive Artifacts
82 uses: actions/upload-artifact@v4
83 with:
84 name: windows-linux-builds
85 path: |
86 *.zip
87 *.tar.gz
88 #if-no-files-found: error
89
90 build_runner_native:
91 name: Build on Native Runner (target OS/CPU = source OS/CPU)
92 strategy:
93 matrix:
94 runner: [macos_x64, raspberry_pi_64, raspberry_pi_32]
95 runs-on: ${{ matrix.runner }}
96 steps:
97 - uses: actions/checkout@v4
98
99 # Setup Castle Game Engine
100 - name: Castle Game Engine - Env CASTLE_ENGINE_PATH
101 run: echo "CASTLE_ENGINE_PATH=$GITHUB_WORKSPACE/castle-engine" >> $GITHUB_ENV
102 - name: Castle Game Engine - Env PATH (non-Windows)
103 run: echo "PATH=$PATH:$CASTLE_ENGINE_PATH/tools/build-tool/" >> $GITHUB_ENV
104 - name: Castle Game Engine - Clone ${{ env.engine_tag }}
105 run: git clone --depth 1 --single-branch --branch ${{ env.engine_tag }} https://github.com/castle-engine/castle-engine/
106 - name: Castle Game Engine - Build
107 run: cd $CASTLE_ENGINE_PATH/tools/build-tool/ && ./castle-engine_compile.sh
108
109 # Package application
110 - name: Package (non macOS)
111 if: ${{ matrix.runner != 'macos_x64' }}
112 run: |
113 castle-engine compile --manifest-name=CastleEngineManifest.converter.xml
114 castle-engine package
115 - name: Package (macOS)
116 if: ${{ matrix.runner == 'macos_x64' }}
117 # Special order for macOS:
118 # - First compile and package castle-model-viewer, it will be a bundle.
119 # - Add 2nd exe "castle-model-converter" to the bundle.
120 # - zip it manually
121 # (TODO: we could add file to zip created by initial "package" instead?)
122 run: |
123 castle-engine compile --manifest-name=CastleEngineManifest.converter.xml
124 castle-engine package --package-format=mac-app-bundle
125
126 cp castle-model-converter castle-model-viewer.app/Contents/MacOS/
127 VERSION=`castle-engine output version`
128 ZIPNAME=castle-model-viewer-"${VERSION}"-darwin-x86_64.zip
129 zip -r "${ZIPNAME}" castle-model-viewer.app/
130 echo "Packed to ${ZIPNAME}"
131
132 - name: Archive Artifacts
133 uses: actions/upload-artifact@v4
134 with:
135 name: ${{ matrix.runner }}-build
136 path: |
137 *.zip
138 *.tar.gz
139 #if-no-files-found: error
140
141 release:
142 name: Release
143 runs-on: ubuntu-latest
144 # Only upload release if all builds, on all runners, succeeded.
145 needs: [build_docker, build_runner_native]
146 steps:
147 - name: Download packaged releases
148 uses: actions/download-artifact@v4
149 with:
150 merge-multiple: true
151 - name: List downloaded files
152 run: ls -R
153 - name: GH CLI status
154 env:
155 GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
156 run: gh auth status
157 # Releases files in the GitHub release.
158 - name: Release Artifacts
159 if: ${{ github.ref == 'refs/heads/master' }}
160 run: gh release --repo ${{ github.repository }} upload ${{ env.release_tag }} --clobber *.zip *.tar.gz
161 env:
162 GH_TOKEN: ${{ github.token }}
163
164 update-release-tag:
165 name: Update Release Tag (make release tag point to the build commit on master branch)
166 runs-on: ubuntu-latest
167 needs: [release]
168 steps:
169 - uses: actions/checkout@v4
170 - name: Update Release Tag
171 if: ${{ github.ref == 'refs/heads/master' }}
172 run: |
173 # --force allows to overwrite previous tag
174 git tag --force ${{ env.release_tag }}
175 # --force allows to push with overwritten tag
176 git push --force origin ${{ env.release_tag }}