-
Notifications
You must be signed in to change notification settings - Fork 9
215 lines (187 loc) · 7.42 KB
/
cmake_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
name: CMake Build
# Rules: Only run if there's a push to origin/main or a pull request to merge
# a branch into main. Any other branches will NOT be tested, so you must test
# them by yourself, but see #2 for details (this can (should) also be
# discussed there too). The only exception is for 'ci-fixes', having been
# dedicated for CI changes.
on:
push:
branches:
- main
- tenacity-*
- 1.3
defaults:
run:
shell: bash
jobs:
build:
name: ${{ matrix.config.name }}
runs-on: ${{ matrix.config.os }}
strategy:
fail-fast: false
matrix:
config:
- name: Ubuntu
os: ubuntu-latest
arch: x86_64 # as reported by `arch` or `uname -m`
generator: Ninja
compiler_cache: ccache
compiler_cache_path: ~/.ccache
vcpkg_binary_cache: ~/.cache/vcpkg
vcpkg_triplet: x64-linux-dynamic
- name: macOS_Intel
os: macos-latest
arch: Intel # as reported by Apple menu > About This Mac
generator: Ninja
compiler_cache: ccache
compiler_cache_path: ~/Library/Caches/ccache
vcpkg_binary_cache: ~/.cache/vcpkg
vcpkg_triplet: x64-osx-dynamic
#- name: macOS_ARM
# os: macos-latest
# arch: aarch64
# generator: Xcode
# Windows (x86) config
- name: Windows_32bit
os: windows-latest
arch: x86
# FIXME: Ninja is broken on Windows, so use Visual Studio for now
generator: Visual Studio 17 2022
# required so CMake uses MSVC rather than MinGW
cc: cl
cxx: cl
compiler_cache: sccache
compiler_cache_path: C:\Users\runneradmin\AppData\Local\Mozilla\sccache\cache
vcpkg_binary_cache: C:\Users\runneradmin\AppData\Local\vcpkg
vcpkg_triplet: x86-windows
exe_suffix: .exe
# Windows (x64) config
- name: Windows_64bit
os: windows-latest
arch: amd64
# FIXME: Ninja is broken on Windows, so use Visual Studio for now
generator: Visual Studio 17 2022
# required so CMake uses MSVC rather than MinGW
cc: cl
cxx: cl
compiler_cache: sccache
compiler_cache_path: C:\Users\runneradmin\AppData\Local\Mozilla\sccache\cache
vcpkg_binary_cache: C:\Users\runneradmin\AppData\Local\vcpkg
vcpkg_triplet: x64-windows
exe_suffix: .exe
env:
CMAKE_BUILD_TYPE: RelWithDebInfo
CMAKE_C_COMPILER_LAUNCHER: ${{ matrix.config.os.compiler_cache }}
CMAKE_CXX_COMPILER_LAUNCHER: ${{ matrix.config.os.compiler_cache }}
MACOSX_DEPLOYMENT_TARGET: 10.15
VCPKG_DISABLE_METRICS: true
VCPKG_DEFAULT_TRIPLET: ${{ matrix.config.vcpkg_triplet }}
# Windows codesigning
# This variables will be used by all the steps
WINDOWS_CERTIFICATE: ${{ secrets.WINDOWS_CERTIFICATE }}
WINDOWS_CERTIFICATE_PASSWORD: ${{ secrets.WINDOWS_CERTIFICATE_PASSWORD }}
TENACITY_ARCH_LABEL: ${{ matrix.config.arch }}
steps:
- name: Checkout Git repository
uses: actions/checkout@v3
with:
submodules: true
- name: Install dependencies
if: runner.os != 'Windows'
run: |
exec bash "scripts/ci/dependencies.sh"
- name: "[Windows] Install dependencies"
if: runner.os == 'Windows'
shell: pwsh
env:
# Install path of scoop
SCOOP: C:\Scoop\
run: |
echo "C:\Scoop\shims" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
iex "& {$(iwr -useb get.scoop.sh)} -RunAsAdmin"
scoop install sccache
- name: Install Apple codesigning certificates
uses: apple-actions/import-codesign-certs@v1
if: startswith( matrix.config.os, 'macos' ) && github.event_name == 'push' && github.repository_owner == 'audacity'
with:
p12-file-base64: ${{ secrets.APPLE_CERTIFICATE }}
p12-password: ${{ secrets.APPLE_CERTIFICATE_PASSWORD }}
# required for CMake to find Ninja
- name: "[Windows] Set up MSVC Developer Command Prompt"
if: runner.os == 'Windows'
uses: seanmiddleditch/gha-setup-vsdevenv@v4
with:
arch: ${{ matrix.config.arch }}
- name: Get Git commit of vcpkg submodule
run: echo VCPKG_COMMIT=$(git ls-tree HEAD vcpkg | awk '{print $3}') >> ${GITHUB_ENV}
- name: Setup vcpkg cache
uses: actions/cache@v3
with:
# cache the vcpkg executable to avoid having to bootstrap vcpkg every time
path: |
${{ github.workspace }}/vcpkg/vcpkg${{ matrix.config.exe_suffix }}
${{ matrix.config.vcpkg_binary_cache }}
key: ${{ matrix.config.name }}-${{ hashFiles('**/vcpkg.json') }}-${{ env.VCPKG_COMMIT }}-${{ github.run_number }}
restore-keys: |
${{ matrix.config.name }}-${{ hashFiles(' **/vcpkg.json') }}-${{ env.VCPKG_COMMIT }}-
${{ matrix.config.name }}-${{ hashFiles(' **/vcpkg.json') }}-
${{ matrix.config.name }}-
- name: "Set up compiler cache"
uses: actions/cache@v3
with:
path: ${{ matrix.config.compiler_cache_path }}
key: ${{ matrix.config.os }}-${{ matrix.config.arch }}-${{ github.head_ref }}-${{ github.run_number }}
restore-keys: |
${{ matrix.config.os }}-${{ matrix.config.arch }}-${{ github.head_ref }}-
${{ matrix.config.os }}-${{ matrix.config.arch }}-
- name: Configure
run: >-
cmake
-G "${{ matrix.config.generator }}"
-D CMAKE_BUILD_TYPE=${{ env.CMAKE_BUILD_TYPE }}
-D CMAKE_INSTALL_PREFIX=${{ github.workspace }}/build/install
-D VCPKG=ON
-S .
-B build
env:
# Apple code signing
APPLE_CODESIGN_IDENTITY: ${{ secrets.APPLE_CODESIGN_IDENTITY }}
APPLE_NOTARIZATION_USER_NAME: ${{ secrets.APPLE_NOTARIZATION_USER_NAME }}
APPLE_NOTARIZATION_PASSWORD: ${{ secrets.APPLE_NOTARIZATION_PASSWORD }}
CC: ${{ matrix.config.cc }}
CXX: ${{ matrix.config.cxx }}
- name: Build
run: cmake --build build --config ${{ env.CMAKE_BUILD_TYPE }}
- name: "Print compiler cache stats"
run: ${{ matrix.config.compiler_cache }} -s
- name: Install
run: cmake --install build --config ${{ env.CMAKE_BUILD_TYPE }} --verbose
- name: "[Windows] Package"
if: runner.os == 'Windows'
run: cmake --build build --target innosetup --config ${{ env.CMAKE_BUILD_TYPE }}
- name: "[Ubuntu/macOS] Package"
if: runner.os != 'Windows'
working-directory: build
run: >-
cpack
-C ${{ env.CMAKE_BUILD_TYPE }}
-D CPACK_COMMAND_HDIUTIL=${{ github.workspace }}/scripts/ci/macos/repeat_hdiutil.sh
--verbose
&& rm -r package/_CPack_Packages
env:
# VCPKG_LIB_PATH is the location that vcpkg stores its libs once built
VCPKG_LIB_PATH: ${{ github.workspace }}/build/vcpkg_installed/x64-linux-dynamic/debug/lib
- name: Upload package artifact
uses: actions/upload-artifact@v3
with:
name: tenacity_${{ matrix.config.name }}_${{ github.run_id }}_${{ env.GIT_HASH_SHORT }}
path: |
build/package/*
!build/package/_CPack_Packages
if-no-files-found: error
- name: Upload artifact of vcpkg build logs
if: always()
uses: actions/upload-artifact@v3
with:
name: vcpkg-logs-${{ runner.os }}
path: ${{ github.workspace }}/vcpkg/buildtrees/**/*.log