-
Notifications
You must be signed in to change notification settings - Fork 12
361 lines (326 loc) · 11.7 KB
/
release_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
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
# Build Polaris examples and generate releases.
name: Polaris Build
on:
push:
# Build on a push to any branch.
branches:
- '*'
# Build on a push of any tag named v* (v1.0, etc.) and generate a release.
tags:
- 'v*'
jobs:
# Build the C++ example applications.
build_cpp:
name: Build C++ Applications
runs-on: ${{ matrix.os }}
strategy:
matrix:
arch: [x64]
os: [ubuntu-latest]
tool: [cmake, bazel]
compiler: [g++]
include:
- arch: armv7hf
os: ubuntu-latest
tool: bazel
compiler: g++
- arch: aarch64
os: ubuntu-latest
tool: bazel
compiler: g++
# Windows not currently supported by C++ library.
#- arch: x64
# os: windows-latest
# tool: cmake
# compiler: msvc
defaults:
run:
shell: bash
steps:
- uses: actions/checkout@v2
# Environment setup.
- name: Setup Environment (Windows)
if: matrix.os == 'windows-latest'
run: |
echo "EXT=.exe" >> $GITHUB_ENV
- name: Setup Environment (Linux)
if: matrix.os == 'ubuntu-latest'
run: |
echo "CXX=/usr/bin/${{ matrix.compiler }}" >> $GITHUB_ENV
echo "EXT=" >> $GITHUB_ENV
- name: Install msbuild (Windows)
if: matrix.os == 'windows-latest'
uses: microsoft/[email protected]
# CMake build support.
- name: Install CMake 3.16.x
if: matrix.tool == 'cmake'
uses: jwlawson/[email protected]
with:
cmake-version: '3.16.x'
# Note: OpenSSL is installed in the system image and works out of the box.
# Boost used to be maintained by Github, but was removed from the images in
# March 2021 (https://github.com/actions/virtual-environments/issues/2667).
# To get around this, we install it with the apt package for Linux. For
# Windows, we would need to download and install the pre-built binaries from
# https://sourceforge.net/projects/boost/files/boost-binaries.
- name: Install Boost (Linux)
if: matrix.tool == 'cmake' && matrix.os == 'ubuntu-latest'
run: |
sudo apt install -y libboost-all-dev
- name: Install GFlags
if: matrix.tool == 'cmake'
run: |
curl -L https://github.com/gflags/gflags/archive/refs/tags/v2.2.2.tar.gz --output gflags.tar.gz
tar xvzf gflags.tar.gz
cd gflags-2.2.2
cmake -B build -DBUILD_SHARED_LIBS=ON .
cd build
make -j
sudo make install
- name: Install GLog
if: matrix.tool == 'cmake'
run: |
curl -L https://github.com/google/glog/archive/0a2e5931bd5ff22fd3bf8999eb8ce776f159cda6.tar.gz --output glog.tar.gz
tar xvzf glog.tar.gz
cd glog-0a2e5931bd5ff22fd3bf8999eb8ce776f159cda6
cmake -B build -DBUILD_SHARED_LIBS=ON .
cd build
make -j
sudo make install
- name: Setup Build (CMake)
if: matrix.tool == 'cmake'
run: |
mkdir cmake_build
cd cmake_build
cmake -DCMAKE_INSTALL_PREFIX=install ..
- name: Build Library And Examples (CMake, Linux)
if: matrix.tool == 'cmake' && matrix.os == 'ubuntu-latest'
run: |
cd cmake_build
make
make install
- name: Build Library And Examples (CMake, Windows)
if: matrix.tool == 'cmake' && matrix.os == 'windows-latest'
run: |
cd cmake_build
MSBuild.exe p1_polaris_client.sln
- name: Build External Project Example (CMake, Linux)
if: matrix.tool == 'cmake' && matrix.os == 'ubuntu-latest'
run: |
mkdir examples/external_cmake_project/build
cd examples/external_cmake_project/build
cmake ..
make
# Bazel build support.
- name: Use Bazel 4.2.2
if: matrix.tool == 'bazel'
uses: abhinavsingh/setup-bazel@v3
with:
version: 4.2.2
- name: Build Library And Examples (Bazel, Native x64)
if: matrix.tool == 'bazel' && matrix.arch == 'x64'
run: |
bazel build -c opt //:polaris_client
bazel build -c opt //examples:*
- name: Build Library And Examples (Bazel, Cross-Compile)
if: matrix.tool == 'bazel' && matrix.arch != 'x64'
run: |
bazel build -c opt --config=${{ matrix.arch }} //:polaris_client
bazel build -c opt --config=${{ matrix.arch }} //examples:*
# Run unit tests.
- name: Run Unit Tests
if: matrix.arch == 'x64'
env:
POLARIS_API_KEY: ${{ secrets.POLARIS_API_KEY }}
run: |
./test/run_unit_tests.sh --tool=${{ matrix.tool }} --unique-id-prefix=${{ matrix.tool }}_cpp
- name: Run Unit Tests With Installed Libraries (CMake, Linux)
if: matrix.arch == 'x64' && matrix.tool == 'cmake' && matrix.os == 'ubuntu-latest'
env:
POLARIS_API_KEY: ${{ secrets.POLARIS_API_KEY }}
run: |
mv cmake_build/libpolaris_cpp_client.so cmake_build/libpolaris_cpp_client.so.bak
mv cmake_build/c/libpolaris_client.so cmake_build/c/libpolaris_client.so.bak
./test/run_unit_tests.sh --tool=${{ matrix.tool }} --unique-id-prefix=${{ matrix.tool }}_cpp --install-prefix=cmake_build/install
mv cmake_build/libpolaris_cpp_client.so.bak cmake_build/libpolaris_cpp_client.so
mv cmake_build/c/libpolaris_client.so.bak cmake_build/c/libpolaris_client.so
# Package artifacts (Bazel only -- no need to do this for multiple build
# tools).
- name: Create artifact
if: matrix.tool == 'bazel'
run: |
bazel query 'kind("cc_binary", //examples:*)' 2>/dev/null |
sed -e 's|//examples:|bazel-bin/examples/|' |
xargs tar czf polaris_examples.tar.gz --transform 's|^bazel-bin|polaris|'
- name: Upload artifact
if: matrix.tool == 'bazel'
uses: actions/upload-artifact@v1
with:
path: polaris_examples.tar.gz
name: polaris_examples.cpp.${{ matrix.arch }}
# Build the C example applications.
build_c:
name: Build C Applications
runs-on: ${{ matrix.os }}
strategy:
matrix:
arch: [x64]
os: [ubuntu-latest]
tool: [make, cmake, bazel]
compiler: [g++]
#include:
# Windows not currently supported by C library.
# - arch: x64
# os: windows-latest
# tool: cmake
# compiler: msvc
defaults:
run:
shell: bash
working-directory: c
steps:
- uses: actions/checkout@v2
# Environment setup.
- name: Setup Environment (Windows)
if: matrix.os == 'windows-latest'
run: |
echo "EXT=.exe" >> $GITHUB_ENV
- name: Setup Environment (Linux)
if: matrix.os == 'ubuntu-latest'
run: |
echo "CXX=/usr/bin/${{ matrix.compiler }}" >> $GITHUB_ENV
echo "EXT=" >> $GITHUB_ENV
- name: Install msbuild (Windows)
if: matrix.os == 'windows-latest'
uses: microsoft/[email protected]
# GNU Make build support.
- name: Build Library And Examples (GNU Make)
if: matrix.tool == 'make'
run: |
make -j
# CMake build support.
- name: Install CMake 3.18.x
if: matrix.tool == 'cmake'
uses: jwlawson/[email protected]
with:
cmake-version: '3.18.x'
- name: Setup Build (CMake)
if: matrix.tool == 'cmake'
run: |
mkdir cmake_build
cd cmake_build
cmake -DCMAKE_INSTALL_PREFIX=install ..
- name: Build Library And Examples (CMake, Linux)
if: matrix.tool == 'cmake' && matrix.os == 'ubuntu-latest'
run: |
cd cmake_build
make -j
make install
- name: Build Library And Examples (CMake, Windows)
if: matrix.tool == 'cmake' && matrix.os == 'windows-latest'
run: |
cd cmake_build
MSBuild.exe p1_polaris_c_client.sln
- name: Build External Project Example (CMake, Linux)
if: matrix.tool == 'cmake' && matrix.os == 'ubuntu-latest'
run: |
mkdir examples/external_cmake_project/build
cd examples/external_cmake_project/build
cmake ..
make
# Bazel build support.
- name: Use Bazel 4.2.2
if: matrix.tool == 'bazel'
uses: abhinavsingh/setup-bazel@v3
with:
version: 4.2.2
- name: Build Library And Examples (Bazel, Native x64)
if: matrix.tool == 'bazel' && matrix.arch == 'x64'
run: |
bazel build -c opt //:polaris_client
bazel build -c opt //examples:*
- name: Build Library And Examples (Bazel, Cross-Compile)
if: matrix.tool == 'bazel' && matrix.arch != 'x64'
run: |
bazel build -c opt --config=${{ matrix.arch }} //:polaris_client
bazel build -c opt --config=${{ matrix.arch }} //examples:*
# Run unit tests.
- name: Run Unit Tests
if: matrix.arch == 'x64'
env:
POLARIS_API_KEY: ${{ secrets.POLARIS_API_KEY }}
run: |
./test/run_unit_tests.sh --tool=${{ matrix.tool }} --unique-id-prefix=${{ matrix.tool }}_c_
- name: Run Unit Tests With Installed Libraries (CMake, Linux)
if: matrix.arch == 'x64' && matrix.tool == 'cmake' && matrix.os == 'ubuntu-latest'
env:
POLARIS_API_KEY: ${{ secrets.POLARIS_API_KEY }}
run: |
mv cmake_build/libpolaris_client.so cmake_build/libpolaris_client.so.bak
./test/run_unit_tests.sh --tool=${{ matrix.tool }} --unique-id-prefix=${{ matrix.tool }}_c_ --install-prefix=cmake_build/install
mv cmake_build/libpolaris_client.so.bak cmake_build/libpolaris_client.so
# Package artifacts (Bazel only -- no need to do this for multiple build
# tools).
- name: Create artifact
if: matrix.tool == 'bazel'
run: |
bazel query 'kind("cc_binary", //examples:*)' 2>/dev/null |
sed -e 's|//examples:|bazel-bin/examples/|' |
xargs tar czf polaris_examples.tar.gz --transform 's|^bazel-bin|polaris/c|'
- name: Upload artifact
if: matrix.tool == 'bazel'
uses: actions/upload-artifact@v1
with:
path: c/polaris_examples.tar.gz
name: polaris_examples.c.${{ matrix.arch }}
# Create a release only on a tag (not on a branch push).
release:
name: Create Release
if: startsWith(github.ref, 'refs/tags/')
needs: [build_cpp, build_c]
runs-on: ubuntu-latest
outputs:
upload_url: ${{ steps.create_release.outputs.upload_url }}
steps:
- name: Create release
id: create_release
uses: actions/create-release@latest
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref }}
release_name: Release ${{ github.ref }}
draft: false
prerelease: false
upload:
name: Upload Release Assets
needs: [release]
runs-on: ubuntu-latest
strategy:
matrix:
lang: [cpp, c]
arch: [x64, armv7hf, aarch64]
exclude:
- {lang: c, arch: armv7hf}
- {lang: c, arch: aarch64}
steps:
- name: Download artifact
uses: actions/download-artifact@v1
with:
name: polaris_examples.${{ matrix.lang }}.${{ matrix.arch }}
- name: Set asset filename
id: release_info
env:
TAG_REF_NAME: ${{ github.ref }}
run: |
# polaris_examples-v1.0.0.cpp.aarch64.tar.gz
echo ::set-output name=file_name::polaris_examples-${TAG_REF_NAME##*/v}.${{ matrix.lang }}.${{ matrix.arch }}.tar.gz
- name: Upload release asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ needs.release.outputs.upload_url }}
asset_path: polaris_examples.${{ matrix.lang }}.${{ matrix.arch }}/polaris_examples.tar.gz
asset_name: ${{ steps.release_info.outputs.file_name }}
asset_content_type: application/tar+gzip