-
Notifications
You must be signed in to change notification settings - Fork 28
226 lines (196 loc) · 7.76 KB
/
build.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
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
name: Build
on:
push:
branches:
- master # Automatically build on push to master
pull_request:
branches:
- master # Automatically build on pull request to master
release:
types:
- published # Automatically build on release
# Grant content write permissions so that the actions can attach artifacts to the releases
permissions:
contents: write
env:
WINDOWS_CEF_VERSION: '114.0.5735.199'
LINUX_CEF_VERSION: '114.0.5735.134'
LUAJIT_VERSION: '2.1'
ENABLE_WINDOWS_RELEASES: 'true'
ENABLE_LINUX_RELEASES: 'true'
jobs:
build-windows-project:
name: Build Windows
runs-on: windows-2022
steps:
- name: Checkout Project
uses: actions/checkout@v4.2.0
with:
path: Bolt
submodules: recursive
- name: Add msbuild to PATH
uses: microsoft/setup-msbuild@v2
with:
vs-version: 17.0
- uses: ilammy/msvc-dev-cmd@v1.13.0
with:
arch: x64
- name: Setup cmake
uses: jwlawson/actions-setup-cmake@v2
with:
cmake-version: '3.30.x'
- name: Create Directories
run: |
mkdir cef
- name: Restore LuaJIT from Cache
id: restore-cache-luajit
uses: actions/cache/restore@v4
with:
path: LuaJIT
key: 'windows-luajit-${{ env.LUAJIT_VERSION }}'
- name: Checkout LuaJIT
if: steps.restore-cache-luajit.outputs.cache-hit != 'true'
uses: actions/checkout@v4.2.0
with:
path: LuaJIT
repository: LuaJIT/LuaJIT
ref: v${{ env.LUAJIT_VERSION }}
- name: Build LuaJIT
if: steps.restore-cache-luajit.outputs.cache-hit != 'true'
run: |
cd LuaJIT/src
.\msvcbuild.bat
- name: Save LuaJIT to Cache
if: steps.restore-cache-luajit.outputs.cache-hit != 'true'
uses: actions/cache/save@v4
with:
path: LuaJIT
key: 'windows-luajit-${{ env.LUAJIT_VERSION }}'
- name: Restore CEF from Cache
id: restore-cef-cache
uses: actions/cache/restore@v4
with:
path: Bolt\cef\dist
key: 'windows-cef-${{ env.WINDOWS_CEF_VERSION }}'
- name: Download CEF
if: steps.restore-cef-cache.outputs.cache-hit != 'true'
run: |
Invoke-WebRequest -Uri 'https://adamcake.com/cef/cef-${{ env.WINDOWS_CEF_VERSION }}-windows64-minimal-ungoogled.zip' -OutFile 'cef.zip'
Expand-Archive -Path 'cef.zip' -DestinationPath 'cef'
Copy-Item -Path (Get-ChildItem -Path "cef" -Directory | Select-Object -First 1).FullName -Destination "Bolt\cef\dist" -Recurse
- name: Save CEF to Cache
if: steps.restore-cef-cache.outputs.cache-hit != 'true'
uses: actions/cache/save@v4
with:
path: Bolt\cef\dist
key: 'windows-cef-${{ env.WINDOWS_CEF_VERSION }}'
# At this point the file tree looks like
# D:\a\Bolt\Bolt
# - LuaJIT
# - <whole luaJIT source>
# - Bolt
# - <whole Bolt source>
# - cef
# - dist
# - <CEF release distribution>
#
# The tree has many nested Bolt dirs because of how GHA works.
# The first two Bolt dirs (D:\a\Bolt\Bolt) are the workspace provided by github.
# Github always does it this way.
# Then github normally clones directly in to the workspace with a folder of the repo name.
# However for our usecase we clone multiple repos, so we have D:\a\Bolt\Bolt\{LuaJIT, Bolt}
- name: Build Project
uses: threeal/cmake-action@v2.0.0
with:
source-dir: Bolt # The directory where CMakeLists.txt is located
build-dir: build # Makes it so that the build directory is set to Bolt/build
generator: Visual Studio 17
options: |
BOLT_LUAJIT_DIR=D:\a\Bolt\Bolt\LuaJIT\src
CMAKE_BUILD_TYPE=Release
BOLT_CEF_INSTALLDIR=D:\a\Bolt\Bolt\install-location
build-args: --config Release -j 4
# Installs to D:\a\Bolt\Bolt\install-location\bolt-launcher\*
- name: Create Release
run: cmake --install build/
# Uploads D:\a\Bolt\Bolt\install-location as a zip
# With `bolt-launcher` as the root directory of the zip file
- name: Upload Build Artifact
uses: actions/upload-artifact@v4
with:
name: Bolt-Windows-${{ github.sha }}
path: D:\a\Bolt\Bolt\install-location
# Uploads the zip file to the release matching the format of the above step
# Such that build artifacts and release artifacts are the same
- name: Attach Bolt Artifact to Release
if: github.event_name == 'release' && env.ENABLE_WINDOWS_RELEASES == 'true'
env:
GH_TOKEN: ${{ github.token }}
# In the script below we cd in to Bolt first, because otherwise the gh command will fail.
run: |
cd Bolt
Compress-Archive -Path D:\a\Bolt\Bolt\install-location\bolt-launcher -DestinationPath D:\a\Bolt\Bolt\Bolt-Windows.zip
gh release upload ${{ github.event.release.tag_name }} D:\a\Bolt\Bolt\Bolt-Windows.zip
build-linux-project:
name: Build Linux
runs-on: ubuntu-24.04
steps:
- name: Checkout Project
uses: actions/checkout@v4.2.0
with:
submodules: recursive
- name: Install package dependencies
run: sudo apt update && sudo apt install -y libx11-dev libxcb1-dev libarchive-dev libluajit-5.1-dev clang cmake ninja-build
- name: Restore CEF from Cache
id: restore-cef-cache
uses: actions/cache/restore@v4
with:
path: cef/dist
key: 'linux-cef-${{ env.LINUX_CEF_VERSION }}'
- name: Download CEF
if: steps.restore-cef-cache.outputs.cache-hit != 'true'
run: |
# Download cef and set up the directory structure
curl -o cef/cef.tar.gz 'https://adamcake.com/cef/cef-${{ env.LINUX_CEF_VERSION }}-linux-x86_64-minimal-ungoogled.tar.gz'
mkdir -p cef/dist
# Extract the cef tarball and copy the contents to the dist directory
tar -xzf cef/cef.tar.gz --directory cef/dist
cef_content_dir=$(ls -d cef/dist/* | head -n 1)
mv "$cef_content_dir"/* cef/dist/
# Clean up the extracted directory
rm -rf "$cef_content_dir"
- name: Save CEF to Cache
if: steps.restore-cef-cache.outputs.cache-hit != 'true'
uses: actions/cache/save@v4
with:
path: cef/dist
key: 'linux-cef-${{ env.LINUX_CEF_VERSION }}'
- name: Build Project
uses: threeal/cmake-action@v2.0.0
with:
build-dir: build # Makes it so that the build directory is set to ./build
generator: Ninja
options: |
BOLT_LUAJIT_INCLUDE_DIR=/usr/include/luajit-2.1
CMAKE_BUILD_TYPE=Release
build-args: --config Release -j 4
- name: Create Release
run: |
cmake --install build/ --prefix install
chmod +x install/opt/bolt-launcher/bolt
- name: Upload Build Artifact
uses: actions/upload-artifact@v4
with:
name: Bolt-Linux-${{ github.sha }}
path: install/opt/
# Uploads the zip file to the release matching the format of the above step
# Such that build artifacts and release artifacts are the same
- name: Attach Bolt Artifact to Release
if: github.event_name == 'release' && env.ENABLE_LINUX_RELEASES == 'true'
env:
GH_TOKEN: ${{ github.token }}
run: |
cd install/opt
zip -r ../../Bolt-Linux.zip .
cd ../../
gh release upload ${{ github.event.release.tag_name }} Bolt-Linux.zip