-
Notifications
You must be signed in to change notification settings - Fork 0
137 lines (119 loc) · 4.23 KB
/
cmake-multi-platform.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
# This starter workflow is for a CMake project running on multiple platforms. There is a different starter workflow if you just want a single platform.
# See: https://github.com/actions/starter-workflows/blob/main/ci/cmake-single-platform.yml
name: Build ChessEngines for Mac, Linux, and Windows using CMake
on:
push:
branches: [ "release" ]
tags: [ "v*" ]
jobs:
build:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
build_type: [Release]
include:
- os: windows-latest
c_compiler: cl
cpp_compiler: cl
- os: ubuntu-latest
c_compiler: gcc
cpp_compiler: g++
- os: ubuntu-latest
c_compiler: clang
cpp_compiler: clang++
- os: macos-latest
c_compiler: clang
cpp_compiler: clang++
exclude:
- os: windows-latest
c_compiler: gcc
- os: windows-latest
c_compiler: clang
- os: ubuntu-latest
c_compiler: cl
steps:
- uses: actions/checkout@v4
- name: Install Dependencies (Linux only)
if: matrix.os == 'ubuntu-latest'
run: sudo apt-get update && sudo apt-get install -y libgl1-mesa-dev libx11-dev libudev-dev libopenal-dev libvorbis-dev libogg-dev libflac-dev libxrandr-dev libxcursor-dev
- name: Set reusable strings
id: strings
shell: bash
run: |
echo "build-output-dir=${{ github.workspace }}/build" >> "$GITHUB_OUTPUT"
- name: Configure CMake
run: >
cmake -B ${{ steps.strings.outputs.build-output-dir }}
-DCMAKE_CXX_COMPILER=${{ matrix.cpp_compiler }}
-DCMAKE_C_COMPILER=${{ matrix.c_compiler }}
-DCMAKE_BUILD_TYPE=${{ matrix.build_type }}
-S ${{ github.workspace }}
- name: Build
run: cmake --build ${{ steps.strings.outputs.build-output-dir }} --config ${{ matrix.build_type }}
- name: Package Binary
run: |
mkdir -p release
if [[ "${{ matrix.os }}" == "windows-latest" ]]; then
cp ${{ steps.strings.outputs.build-output-dir }}/*.exe release/
else
cp ${{ steps.strings.outputs.build-output-dir }}/* release/
fi
tar -czvf ${{ matrix.os }}-release.tar.gz -C release .
- name: Upload Artifact
uses: actions/upload-artifact@v2
with:
name: ${{ matrix.os }}-binary
path: ${{ matrix.os }}-release.tar.gz
release:
needs: build
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Download Windows Artifact
uses: actions/download-artifact@v2
with:
name: windows-latest-binary
- name: Download Linux Artifact
uses: actions/download-artifact@v2
with:
name: ubuntu-latest-binary
- name: Download MacOS Artifact
uses: actions/download-artifact@v2
with:
name: macos-latest-binary
- name: Create GitHub Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref }}
release_name: Release ${{ github.ref }}
body: |
Release notes for ${{ github.ref }}
draft: false
prerelease: false
- name: Upload Windows Release Asset
uses: actions/upload-release-asset@v1
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: windows-latest-release.tar.gz
asset_name: windows-latest-release.tar.gz
asset_content_type: application/gzip
- name: Upload Linux Release Asset
uses: actions/upload-release-asset@v1
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ubuntu-latest-release.tar.gz
asset_name: ubuntu-latest-release.tar.gz
asset_content_type: application/gzip
- name: Upload MacOS Release Asset
uses: actions/upload-release-asset@v1
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: macos-latest-release.tar.gz
asset_name: macos-latest-release.tar.gz
asset_content_type: application/gzip