forked from OpenBrickProtocolFoundation/oopetris
-
Notifications
You must be signed in to change notification settings - Fork 0
104 lines (88 loc) · 3.89 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
name: CMake CI
on:
push:
branches: ["main"]
pull_request:
workflow_dispatch:
jobs:
build:
name: ${{ matrix.config.name }}
runs-on: ${{ matrix.config.os }}-${{ matrix.config.os-version }}
strategy:
fail-fast: false
matrix:
# Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.)
config:
- name: Windows MSVC Release
os: windows
os-version: 2022
msvc: true
buildtype: Release
- name: Linux Release
os: ubuntu
os-version: 22.04
buildtype: Release
steps:
- uses: actions/checkout@v4
with:
fetch-depth: "0"
- name: Setup MSVC
if: matrix.config.os == 'windows' && matrix.config.msvc == true
uses: TheMrMilchmann/setup-msvc-dev@v3
with:
arch: x64
toolset: 14.39
- name: Install dependencies (Linux)
if: matrix.config.os == 'ubuntu'
shell: bash
run: |
sudo apt-get update
sudo apt install curl pkg-config zip unzip tar cmake git -y
- name: Install cmake >= 3.25 (Linux)
if: matrix.config.os == 'ubuntu'
shell: bash
run: |
sudo apt-get update
sudo apt-get install gpg wget
wget -O - https://apt.kitware.com/keys/kitware-archive-latest.asc 2>/dev/null | gpg --dearmor - | sudo tee /usr/share/keyrings/kitware-archive-keyring.gpg >/dev/null
echo 'deb [signed-by=/usr/share/keyrings/kitware-archive-keyring.gpg] https://apt.kitware.com/ubuntu/ jammy main' | sudo tee /etc/apt/sources.list.d/kitware.list >/dev/null
sudo apt-get update
sudo apt-get install cmake -y
- name: Setup GCC (Linux)
if: matrix.config.os == 'ubuntu'
uses: egor-tensin/setup-gcc@v1
with:
version: 13
platform: x64
- name: Install vcpkg
shell: bash
run: |
cd "${{github.workspace}}"
git clone https://github.com/Microsoft/vcpkg.git
"${{github.workspace}}/vcpkg/bootstrap-vcpkg.sh"
- uses: abdes/gha-setup-ninja@master
- name: Configure CMake (Windows only)
if: matrix.config.os == 'windows'
# 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 ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{ matrix.config.buildtype }} -DCMAKE_TOOLCHAIN_FILE="${{github.workspace}}/vcpkg/scripts/buildsystems/vcpkg.cmake" ${{github.workspace}} -DVCPKG_TARGET_TRIPLET=x64-windows-static -G Ninja
- name: Configure CMake (Linux only)
if: matrix.config.os == 'ubuntu'
# 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 ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{ matrix.config.buildtype }} -DCMAKE_TOOLCHAIN_FILE="${{github.workspace}}/vcpkg/scripts/buildsystems/vcpkg.cmake" ${{github.workspace}} -G Ninja
- name: Build
# Build your program with the given configuration
run: cmake --build ${{github.workspace}}/build -j --config ${{ matrix.config.buildtype }}
- name: Upload artifacts - Linux
uses: actions/upload-artifact@v4
if: matrix.config.os == 'ubuntu'
with:
name: ${{ matrix.config.name }} Executable
path: build/oopetris
- name: Upload artifacts - Windows
uses: actions/upload-artifact@v4
if: matrix.config.os == 'windows'
with:
name: ${{ matrix.config.name }} Executable
path: build\oopetris.exe