-
Notifications
You must be signed in to change notification settings - Fork 0
184 lines (162 loc) · 5.68 KB
/
Copy pathcpp-cmake-ci.yml
File metadata and controls
184 lines (162 loc) · 5.68 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
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
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@v4
- name: Install Linux system packages
if: runner.os == 'Linux'
shell: bash
run: |
sudo apt-get update
sudo apt-get install -y ninja-build
- 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@v4
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 ONNX Runtime on Windows
if: runner.os == 'Windows'
shell: pwsh
run: |
& "$env:VCPKG_ROOT\vcpkg.exe" install "onnxruntime:${{ matrix.vcpkg_triplet }}"
- name: Install ONNX Runtime on Linux
if: runner.os == 'Linux'
shell: bash
run: |
"$VCPKG_ROOT/vcpkg" install "onnxruntime:${{ 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/bin/${APP_NAME}" "${package_dir}/"
cp README.md "${package_dir}/"
if [ -f "models/cat_vs_dog/best.onnx" ]; then
mkdir -p "${package_dir}/models/cat_vs_dog"
cp "models/cat_vs_dog/best.onnx" "${package_dir}/models/cat_vs_dog/"
fi
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@v4
with:
name: ${{ matrix.artifact_name }}
path: dist/${{ matrix.artifact_name }}.zip
if-no-files-found: error
- name: Upload Linux artifact
if: runner.os == 'Linux'
uses: actions/upload-artifact@v4
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