-
Notifications
You must be signed in to change notification settings - Fork 0
197 lines (170 loc) · 6.74 KB
/
ci.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
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
name: CI
on:
push:
branches: [main]
pull_request:
branches: [main]
permissions:
contents: write
deployments: write
jobs:
build:
name: ${{ matrix.platform }}-${{ matrix.arch }}-${{ matrix.compiler }}
runs-on: ${{ matrix.run-on }}
strategy:
fail-fast: false
matrix:
run-on: [ubuntu-latest, windows-latest]
compiler: [any]
include:
- run-on: windows-latest
triplet: x64-windows-static-release
arch: x86_64
platform: windows
compiler: msvc
- run-on: ubuntu-latest
triplet: x64-linux-release
arch: x86_64
platform: linux
compiler: gcc
- run-on: ubuntu-latest
triplet: x64-linux-release
arch: x86_64
platform: linux
compiler: clang
exclude:
- compiler: any
env:
VCPKG_DEFAULT_TRIPLET: ${{ matrix.triplet }}
VCPKG_GIT_COMMIT_ID: "c82f74667287d3dc386bce81e44964370c91a289"
steps:
- name: Install gcc-13
if: runner.os == 'Linux'
run: |
sudo add-apt-repository ppa:ubuntu-toolchain-r/test
sudo apt update
sudo apt install gcc-13 g++-13
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-13 60 --slave /usr/bin/g++ g++ /usr/bin/g++-13
- name: Install clang-17(dev)
if: runner.os == 'Linux' && matrix.compiler == 'clang'
run: |
wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | sudo apt-key add -
sudo add-apt-repository 'deb http://apt.llvm.org/jammy/ llvm-toolchain-jammy-17 main'
sudo apt update
sudo apt install clang-17
echo "CC=clang-17" >> $GITHUB_ENV
echo "CXX=clang++-17" >> $GITHUB_ENV
- uses: actions/checkout@v4
with:
lfs: 'false'
- name: Create LFS file list
shell: pwsh
run: git lfs ls-files -l | ForEach-Object { $_.split(" ")[0] } | Sort-Object | Out-File .lfs-assets-id
- name: Restore LFS cache
uses: actions/cache@v4
id: lfs-cache
with:
path: .git/lfs
key: ${{ runner.os }}-lfs-${{ hashFiles('.lfs-assets-id') }}-v1
- name: Git LFS Pull
run: git lfs pull
- uses: lukka/get-cmake@latest
with:
cmakeVersion: "~3.25.0"
ninjaVersion: "^1.11.1"
- uses: TheMrMilchmann/setup-msvc-dev@v2
if: runner.os == 'Windows'
with:
arch: x64
- name: Setup vcpkg (windows)
if: runner.os == 'Windows'
run: |
cd "C:\"
if(Test-Path C:\vcpkg) { rm -r -Force "C:\vcpkg" }
git clone --depth 1 --branch "2024.09.30" https://github.com/microsoft/vcpkg.git
- name: Restore vcpkg-tool (windows)
if: runner.os == 'Windows'
id: restore-vcpkg-tool
uses: actions/cache/restore@v3
with:
path: C:\vcpkg\vcpkg.exe
key: windows-cache-vcpkg-tool
- name: Build vcpkg-tool (windows)
if: runner.os == 'Windows' && steps.restore-vcpkg-tool.outputs.cache-hit != 'true'
run: |
cd "C:\"
if(Test-Path C:\vcpkg-tool) { rm -r -Force "C:\vcpkg-tool" }
git clone --depth 1 --branch gha-upload-fixes https://github.com/albertziegenhagel/vcpkg-tool.git
cd "C:\vcpkg-tool"
mkdir build
cd build
cmake .. -G Ninja -DCMAKE_BUILD_TYPE=Release
ninja
cp .\vcpkg.exe C:\vcpkg\
- name: Store vcpkg-tool (windows)
if: runner.os == 'Windows' && steps.restore-vcpkg-tool.outputs.cache-hit != 'true'
uses: actions/cache/save@v3
with:
path: C:\vcpkg\vcpkg.exe
key: ${{ steps.restore-vcpkg-tool.outputs.cache-primary-key }}
- name: Setup GHA cache
if: runner.os == 'Windows'
uses: actions/github-script@v6
with:
script: |
core.exportVariable('ACTIONS_CACHE_URL', process.env.ACTIONS_CACHE_URL || '');
core.exportVariable('ACTIONS_RUNTIME_TOKEN', process.env.ACTIONS_RUNTIME_TOKEN || '');
- name: Setup vcpkg (non-windows)
if: runner.os != 'Windows'
uses: lukka/run-vcpkg@v11
with:
vcpkgGitCommitId: "${{ env.VCPKG_GIT_COMMIT_ID }}"
- name: Build & Test project (Windows)
if: runner.os == 'Windows'
run: |
cd '${{ github.workspace }}'
$env:VCPKG_BINARY_SOURCES="clear;x-gha,readwrite"
cmake --preset ci . -G Ninja -DCMAKE_TOOLCHAIN_FILE=C:\vcpkg\scripts\buildsystems\vcpkg.cmake -DCMAKE_BUILD_TYPE=Release "-DVCPKG_TARGET_TRIPLET=${{ matrix.triplet }}" "-DVCPKG_INSTALL_OPTIONS=--debug"
cmake --build --preset ci .
ctest --preset ci
- name: Build & Test project (default)
uses: lukka/run-cmake@v10
if: runner.os == 'Linux'
with:
configurePreset: "ci"
configurePresetAdditionalArgs: "['-DCMAKE_BUILD_TYPE=Release', '-DVCPKG_TARGET_TRIPLET=${{ matrix.triplet }}', '-DVCPKG_VERBOSE=ON', '-DVCPKG_INSTALL_OPTIONS=--debug']"
buildPreset: "ci"
testPreset: "ci"
- name: Install
run: |
cmake --install ${{ github.workspace }}/build/ci --component server --prefix ${{ github.workspace }}/install/server
cmake --install ${{ github.workspace }}/build/ci --component tools --prefix ${{ github.workspace }}/install/tools
- name: Create build info
shell: pwsh
run: |
"ref: ${{ github.ref_name }}`n" + `
"commit: ${{ github.sha }}`n" + `
"date: $(Get-Date -UFormat '%FT%T%Z' -AsUTC)" | Out-File -Path "${{ github.workspace }}/install/info.txt"
cp ${{ github.workspace }}/install/info.txt ${{ github.workspace }}/install/server/bin/
cp ${{ github.workspace }}/install/info.txt ${{ github.workspace }}/install/tools/bin/
- name: Upload server binaries
uses: actions/upload-artifact@v4
if: runner.os != 'Linux' || matrix.compiler == 'gcc'
with:
name: snail-server-${{ matrix.arch }}-${{ matrix.platform }}
path: |
${{ github.workspace }}/install/server/bin/snail-server*
${{ github.workspace }}/install/server/bin/info.txt
- name: Upload tool binaries
uses: actions/upload-artifact@v4
if: runner.os != 'Linux' || matrix.compiler == 'gcc'
with:
name: snail-tools-${{ matrix.arch }}-${{ matrix.platform }}
path: |
${{ github.workspace }}/install/tools/bin/snail-tool-*
${{ github.workspace }}/install/tools/bin/info.txt
deploy-head:
name: "Deploy head"
needs: build
if: github.ref == 'refs/heads/main'
uses: ./.github/workflows/deploy-head.yml