Skip to content

Commit 2628764

Browse files
Restore multi-platform build and remove setup.sh
Co-authored-by: Matt-DESTROYER <69026158+Matt-DESTROYER@users.noreply.github.com>
1 parent 458e4d2 commit 2628764

2 files changed

Lines changed: 96 additions & 28 deletions

File tree

.github/workflows/build.yml

Lines changed: 96 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,44 @@ permissions:
1212

1313
jobs:
1414
build:
15-
runs-on: ubuntu-latest
15+
runs-on: ${{ matrix.os }}
16+
17+
strategy:
18+
fail-fast: false
19+
matrix:
20+
os: [ubuntu-latest, macos-latest, windows-latest]
21+
build_type: [Release]
22+
c_compiler: [clang, cl]
23+
include:
24+
- os: windows-latest
25+
c_compiler: cl
26+
cpp_compiler: cl
27+
generator_args: "-A x64"
28+
- os: ubuntu-latest
29+
c_compiler: clang
30+
cpp_compiler: clang++
31+
generator_args: ""
32+
- os: macos-latest
33+
c_compiler: clang
34+
cpp_compiler: clang++
35+
generator_args: ""
36+
exclude:
37+
- os: windows-latest
38+
c_compiler: clang
39+
- os: ubuntu-latest
40+
c_compiler: cl
41+
- os: macos-latest
42+
c_compiler: cl
1643

1744
steps:
45+
- name: Install dependencies (Linux)
46+
if: matrix.os == 'ubuntu-latest'
47+
run: >
48+
sudo apt-get update && sudo apt-get install -y
49+
build-essential cmake clang libx11-dev libxrandr-dev
50+
libxinerama-dev libxcursor-dev libxi-dev libgl1-mesa-dev
51+
libwayland-dev wayland-protocols libxkbcommon-dev pkg-config
52+
1853
- name: Checkout
1954
uses: actions/checkout@v6
2055
with:
@@ -25,24 +60,76 @@ jobs:
2560
uses: actions/cache@v5
2661
with:
2762
path: ${{ github.workspace }}/glfw
28-
key: glfw-${{ runner.os }}-${{ hashFiles('glfw/**') }}
29-
30-
- name: Dependencies
31-
run: bash ./setup.sh
63+
key: glfw-${{ runner.os }}-${{ matrix.c_compiler }}-${{ hashFiles('glfw/**') }}
64+
65+
- name: Configure CMake for GLFW
66+
run: >
67+
cmake -S ${{ github.workspace }}/glfw -B ${{ github.workspace }}/glfw/build
68+
-DCMAKE_C_COMPILER=${{ matrix.c_compiler }}
69+
-DCMAKE_BUILD_TYPE=${{ matrix.build_type }}
70+
-DCMAKE_INSTALL_PREFIX=${{ github.workspace }}/glfw/install
71+
-DBUILD_SHARED_LIBS=OFF
72+
-DGLFW_BUILD_EXAMPLES=OFF
73+
-DGLFW_BUILD_TESTS=OFF
74+
-DGLFW_BUILD_DOCS=OFF
75+
-DGLFW_INSTALL=ON
76+
${{ matrix.generator_args }}
77+
78+
- name: Build and install GLFW
79+
run: |
80+
cmake --build ${{ github.workspace }}/glfw/build --config ${{ matrix.build_type }}
81+
cmake --install ${{ github.workspace }}/glfw/build --config ${{ matrix.build_type }}
82+
83+
- name: Configure Snake
84+
run: >
85+
cmake -S ${{ github.workspace }}/Snake -B ${{ github.workspace }}/Snake/build
86+
-DCMAKE_BUILD_TYPE=${{ matrix.build_type }}
87+
-DGLFW_INCLUDE_DIR=${{ github.workspace }}/glfw/install/include
88+
-DGLFW_LIB_DIR=${{ github.workspace }}/glfw/install/lib
89+
${{ matrix.generator_args }}
3290
3391
- name: Build Snake
34-
run: bash ./build.sh
92+
run: >
93+
cmake --build ${{ github.workspace }}/Snake/build
94+
--config ${{ matrix.build_type }}
95+
--target Snake
96+
97+
- name: Prepare artifact directory
98+
shell: bash
99+
run: |
100+
mkdir -p artifact
101+
# Copy executable (platform-specific)
102+
if [ -f "${{ github.workspace }}/Snake/build/${{ matrix.build_type }}/Snake.exe" ]; then
103+
cp "${{ github.workspace }}/Snake/build/${{ matrix.build_type }}/Snake.exe" artifact/
104+
elif [ -f "${{ github.workspace }}/Snake/build/Snake" ]; then
105+
cp "${{ github.workspace }}/Snake/build/Snake" artifact/
106+
fi
107+
# Copy Assets and Shaders directories
108+
cp -r "${{ github.workspace }}/Snake/Assets" artifact/
109+
cp -r "${{ github.workspace }}/Snake/Shaders" artifact/
35110
36111
- name: Attest build provenance
37112
uses: actions/attest-build-provenance@v3
38113
with:
39-
subject-path: "${{ github.workspace }}/Snake/build/Snake"
114+
subject-path: "artifact/*"
115+
116+
- name: Create release archive
117+
shell: bash
118+
run: |
119+
cd artifact
120+
if [ "${{ matrix.os }}" == "windows-latest" ]; then
121+
7z a ../Snake-${{ matrix.os }}.zip *
122+
else
123+
tar -czf ../Snake-${{ matrix.os }}.tar.gz *
124+
fi
40125
41-
- name: Upload artifact
126+
- name: Upload artifact to release
42127
uses: softprops/action-gh-release@v2
43128
if: github.ref_type == 'tag'
44129
with:
45-
files: "${{ github.workspace }}/Snake/build/Snake"
130+
files: |
131+
Snake-${{ matrix.os }}.zip
132+
Snake-${{ matrix.os }}.tar.gz
46133
generate_release_notes: true
47134
env:
48135
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

setup.sh

Lines changed: 0 additions & 19 deletions
This file was deleted.

0 commit comments

Comments
 (0)