-
Notifications
You must be signed in to change notification settings - Fork 0
201 lines (179 loc) · 6.3 KB
/
cpp-cmake-ci.yml
File metadata and controls
201 lines (179 loc) · 6.3 KB
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
name: cpp-cmake-ci
on:
push:
branches:
- master
- main
tags:
- "v*"
pull_request:
branches:
- master
- main
workflow_dispatch:
permissions:
contents: write
env:
APP_NAME: YOLOClassifier
BUILD_TYPE: Release
FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: true
jobs:
build:
name: ${{ matrix.name }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- name: Windows / Qt 5.12.12
os: windows-2022
qt_host: windows
qt_arch: win64_msvc2017_64
vcpkg_triplet: x64-windows
artifact_name: YOLOClassifier-windows-x64
- name: Linux / Qt 5.12.12
os: ubuntu-22.04
qt_host: linux
qt_arch: gcc_64
vcpkg_triplet: x64-linux
artifact_name: YOLOClassifier-linux-x64
steps:
- name: Checkout
uses: actions/checkout@v5
- name: Install Linux system packages
if: runner.os == 'Linux'
shell: bash
run: |
sudo apt-get update
sudo apt-get install -y \
ninja-build \
autoconf \
autoconf-archive \
automake \
libtool \
pkg-config
- name: Setup MSVC
if: runner.os == 'Windows'
uses: ilammy/msvc-dev-cmd@v1
with:
arch: x64
- name: Install Qt 5.12.12
uses: jurplel/install-qt-action@v4
with:
version: 5.12.12
host: ${{ matrix.qt_host }}
target: desktop
arch: ${{ matrix.qt_arch }}
cache: true
install-deps: true
- name: Bootstrap vcpkg on Windows
if: runner.os == 'Windows'
shell: pwsh
run: |
git clone https://github.com/microsoft/vcpkg.git "$env:RUNNER_TEMP\vcpkg"
& "$env:RUNNER_TEMP\vcpkg\bootstrap-vcpkg.bat" -disableMetrics
"VCPKG_ROOT=$env:RUNNER_TEMP\vcpkg" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
- name: Bootstrap vcpkg on Linux
if: runner.os == 'Linux'
shell: bash
run: |
git clone https://github.com/microsoft/vcpkg.git "$RUNNER_TEMP/vcpkg"
"$RUNNER_TEMP/vcpkg/bootstrap-vcpkg.sh" -disableMetrics
echo "VCPKG_ROOT=$RUNNER_TEMP/vcpkg" >> "$GITHUB_ENV"
- name: Restore vcpkg cache
uses: actions/cache@v5
with:
path: |
${{ runner.temp }}/vcpkg/downloads
${{ runner.temp }}/vcpkg/packages
${{ runner.temp }}/vcpkg/installed
key: vcpkg-${{ runner.os }}-${{ matrix.vcpkg_triplet }}-${{ hashFiles('.github/workflows/cpp-cmake-ci.yml', 'CMakeLists.txt') }}
restore-keys: |
vcpkg-${{ runner.os }}-${{ matrix.vcpkg_triplet }}-
- name: Install C++ dependencies on Windows
if: runner.os == 'Windows'
shell: pwsh
run: |
& "$env:VCPKG_ROOT\vcpkg.exe" install `
"onnxruntime:${{ matrix.vcpkg_triplet }}" `
"opencv4[core,jpeg,png,webp]:${{ matrix.vcpkg_triplet }}"
- name: Install C++ dependencies on Linux
if: runner.os == 'Linux'
shell: bash
run: |
"$VCPKG_ROOT/vcpkg" install \
"onnxruntime:${{ matrix.vcpkg_triplet }}" \
"opencv4[core,jpeg,png,webp]:${{ matrix.vcpkg_triplet }}"
- name: Configure on Windows
if: runner.os == 'Windows'
shell: pwsh
run: |
cmake -S . -B build -G Ninja `
"-DCMAKE_BUILD_TYPE=${env:BUILD_TYPE}" `
"-DCMAKE_TOOLCHAIN_FILE=$env:VCPKG_ROOT\scripts\buildsystems\vcpkg.cmake" `
"-DVCPKG_TARGET_TRIPLET=${{ matrix.vcpkg_triplet }}" `
"-DQt5_DIR=$env:Qt5_DIR"
- name: Configure on Linux
if: runner.os == 'Linux'
shell: bash
run: |
cmake -S . -B build -G Ninja \
-DCMAKE_BUILD_TYPE="${BUILD_TYPE}" \
-DCMAKE_TOOLCHAIN_FILE="$VCPKG_ROOT/scripts/buildsystems/vcpkg.cmake" \
-DVCPKG_TARGET_TRIPLET="${{ matrix.vcpkg_triplet }}" \
-DQt5_DIR="${Qt5_DIR}"
- name: Build on Windows
if: runner.os == 'Windows'
shell: pwsh
run: cmake --build build --config $env:BUILD_TYPE --parallel
- name: Build on Linux
if: runner.os == 'Linux'
shell: bash
run: cmake --build build --config "${BUILD_TYPE}" --parallel
- name: Package Windows bundle
if: runner.os == 'Windows'
shell: pwsh
env:
BUILD_DIR: ${{ github.workspace }}\build
DIST_DIR: ${{ github.workspace }}\dist
VCPKG_TRIPLET: ${{ matrix.vcpkg_triplet }}
run: .\scripts\package-windows.ps1
- name: Package Linux artifact
if: runner.os == 'Linux'
shell: bash
run: |
package_dir="dist/${{ matrix.artifact_name }}"
mkdir -p "${package_dir}"
cp "build/Release/bin/${APP_NAME}" "${package_dir}/"
cp README.md "${package_dir}/"
for model_dir in "models/cat_vs_dog" "models/WellColumnClassification"; do
if [ -d "${model_dir}" ]; then
mkdir -p "${package_dir}/${model_dir}"
for file_name in "best.onnx" "labels.txt" "dataset_summary.json"; do
if [ -f "${model_dir}/${file_name}" ]; then
cp "${model_dir}/${file_name}" "${package_dir}/${model_dir}/"
fi
done
fi
done
tar -C dist -czf "dist/${{ matrix.artifact_name }}.tar.gz" "${{ matrix.artifact_name }}"
- name: Upload Windows artifact
if: runner.os == 'Windows'
uses: actions/upload-artifact@v6
with:
name: ${{ matrix.artifact_name }}
path: dist/${{ matrix.artifact_name }}
if-no-files-found: error
- name: Upload Linux artifact
if: runner.os == 'Linux'
uses: actions/upload-artifact@v6
with:
name: ${{ matrix.artifact_name }}
path: dist/${{ matrix.artifact_name }}.tar.gz
if-no-files-found: error
- name: Publish GitHub Release
if: runner.os == 'Windows' && github.ref_type == 'tag'
uses: softprops/action-gh-release@v2
with:
files: dist/${{ matrix.artifact_name }}.zip
generate_release_notes: true