-
-
Notifications
You must be signed in to change notification settings - Fork 115
174 lines (151 loc) · 5.81 KB
/
cmake.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
name: Build
on:
push:
branches: [ master ]
tags:
- '*'
pull_request:
branches: [ master ]
release:
types: [published, created, edited]
env:
VERSION: 2.1.0
CTEST_EXT_COLOR_OUTPUT: TRUE
CTEST_OUTPUT_ON_FAILURE: 1
CTEST_BUILD_FLAGS: -j4
BUILD_TYPE: Release
SDL_AUDIODRIVER: dummy
SDL_VIDEODRIVER: dummy
jobs:
build:
runs-on: ${{ matrix.os }}
strategy:
matrix:
include:
- os: ubuntu-latest
cc: gcc
cc_version: latest
- os: ubuntu-latest
cc: gcc
cc_version: 11
- os: ubuntu-latest
cc: clang
cc_version: latest
- os: ubuntu-latest
cc: clang
cc_version: 12
- os: macos-latest
- os: windows-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install Protoc
uses: arduino/setup-protoc@v3
with:
version: "23.x"
repo-token: ${{ secrets.GITHUB_TOKEN }}
- name: Check stuff
run: |
protoc --version
echo "${{ github.workspace }}"
- name: Set up Homebrew (Linux)
id: set-up-homebrew
if: matrix.os == 'ubuntu-latest'
uses: Homebrew/actions/setup-homebrew@master
- name: Install SDL via homebrew (Linux)
# Because ubuntu 22 doesn't have the latest SDL libs
if: matrix.os == 'ubuntu-latest'
run: brew install sdl2 sdl2_mixer sdl2_image
- name: Install packages (Linux)
if: startsWith(matrix.os, 'ubuntu')
run: |
sudo apt-get update
sudo apt install python3-pip libgl1-mesa-dev
python3 -m pip install protobuf --break-system-packages
pip3 install --upgrade protobuf --break-system-packages
# libsdl2-dev libsdl2-image-dev libsdl2-mixer-dev
- name: Set up GCC (Linux)
if: startsWith(matrix.os, 'ubuntu') && matrix.cc == 'gcc'
uses: egor-tensin/setup-gcc@v1
with:
version: ${{ matrix.cc_version }}
- name: Set up Clang (Linux)
if: startsWith(matrix.os, 'ubuntu') && matrix.cc == 'clang'
uses: egor-tensin/setup-clang@v1
with:
version: ${{ matrix.cc_version }}
- name: Install packages (macOS)
if: matrix.os == 'macos-latest'
run: |
python3 -m pip install protobuf --break-system-packages
pip3 install --upgrade protobuf --break-system-packages
build/macosx/install-sdl2.sh
- name: Install dependencies (Windows)
if: matrix.os == 'windows-latest'
run: C:\vcpkg\vcpkg.exe install --triplet x64-windows sdl2 sdl2-image sdl2-mixer[core,mpg123] protobuf --recurse
- name: Configure CMake
env:
CC: ${{ matrix.cc }}
if: matrix.os != 'windows-latest'
# Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make.
# See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type
run: cmake -B . -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DCMAKE_INSTALL_PREFIX=. -DDATA_INSTALL_DIR=. -Wno-dev
- name: Configure CMake (Windows)
if: matrix.os == 'windows-latest'
run: cmake -B . -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DCMAKE_TOOLCHAIN_FILE=C:\vcpkg\scripts\buildsystems\vcpkg.cmake -DVCPKG_TARGET_TRIPLET=x64-windows
- name: Build
# Build your program with the given configuration
run: cmake --build . --config ${{env.BUILD_TYPE}}
- name: Test
working-directory: ${{github.workspace}}
# Execute tests defined by the CMake configuration.
# See https://cmake.org/cmake/help/latest/manual/ctest.1.html for more detail
run: ctest -C ${{env.BUILD_TYPE}} -VV
- name: Download DLLs on tags (Windows)
if: startsWith(github.ref, 'refs/tags/') && matrix.os == 'windows-latest'
run: |
build/windows/get-sdl2-dlls.bat dll 64
- name: Make package on tags
if: startsWith(github.ref, 'refs/tags/')
run: |
cpack -B . -C ${{env.BUILD_TYPE}}
echo "${{ github.workspace }}"
ls "${{ github.workspace }}"
ls ${{ github.workspace }}/C-Dogs*SDL-*-*.*
- name: Upload a Build Artifact
uses: softprops/action-gh-release@v1
if: >
startsWith(github.ref, 'refs/tags/') &&
(!startsWith(matrix.os, 'ubuntu') || (matrix.cc == 'gcc' && matrix.cc_version == 'latest')) &&
github.event.release.created
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
files: C-Dogs*SDL-*-*.*
fail_on_unmatched_files: true
- name: Publish to itch.io (Linux)
if: startsWith(github.ref, 'refs/tags/') && startsWith(matrix.os, 'ubuntu') && matrix.cc == 'gcc' && matrix.cc_version == 'latest' && github.event.release.created
env:
BUTLER_API_KEY: ${{ secrets.BUTLER_API_KEY }}
run: |
curl -L -o butler.zip https://broth.itch.ovh/butler/linux-amd64/LATEST/archive/default
unzip butler.zip
chmod +x butler
./butler -V
./butler push C-Dogs*SDL-*-Linux.tar.gz congusbongus/cdogs-sdl:linux --userversion $VERSION
- name: Publish to itch.io (macOS)
if: startsWith(github.ref, 'refs/tags/') && matrix.os == 'macos-latest' && github.event.release.created
env:
BUTLER_API_KEY: ${{ secrets.BUTLER_API_KEY }}
run: |
curl -L -o butler.zip https://broth.itch.ovh/butler/darwin-amd64/LATEST/archive/default
unzip butler.zip
chmod +x butler
./butler -V
./butler push C-Dogs*SDL-*-OSX.dmg congusbongus/cdogs-sdl:mac --userversion $VERSION
- name: Publish to itch.io (Windows)
if: startsWith(github.ref, 'refs/tags/') && matrix.os == 'windows-latest' && github.event.release.created
env:
BUTLER_API_KEY: ${{ secrets.BUTLER_API_KEY }}
run: |
.\build\windows\butler.bat