CI: Use dynamic MSVC run-time library
[qBittorrent.git] / .github / workflows / ci_windows.yaml
blobfa2f871df92ed5499a737ba846a539d0f3d29096
1 name: CI - Windows
3 on: [pull_request, push]
5 permissions:
6   actions: write
8 concurrency:
9   group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
10   cancel-in-progress: ${{ github.head_ref != '' }}
12 jobs:
13   ci:
14     name: Build
15     runs-on: windows-latest
17     strategy:
18       fail-fast: false
19       matrix:
20         libt_version: ["2.0.9", "1.2.19"]
22     env:
23       boost_path: "${{ github.workspace }}/../boost"
24       libtorrent_path: "${{ github.workspace }}/libtorrent"
26     steps:
27       - name: Checkout repository
28         uses: actions/checkout@v4
30       - name: Setup devcmd
31         uses: ilammy/msvc-dev-cmd@v1
33       - name: Install build tools
34         run: |
35           choco install ninja
37       # use the preinstalled vcpkg from image
38       # https://github.com/actions/virtual-environments/blob/main/images/win/Windows2019-Readme.md#package-management
39       - name: Setup vcpkg
40         uses: lukka/run-vcpkg@v11
41         with:
42           vcpkgDirectory: C:/vcpkg
43           doNotUpdateVcpkg: true  # the preinstalled vcpkg is updated regularly
45       - name: Install dependencies from vcpkg
46         run: |
47           # clear buildtrees after each package installation to reduce disk space requirements
48           $packages = `
49             "openssl:x64-windows-static-release",
50             "zlib:x64-windows-static-release"
51           ${{ env.RUNVCPKG_VCPKG_ROOT }}/vcpkg.exe upgrade `
52             --no-dry-run
53           ${{ env.RUNVCPKG_VCPKG_ROOT }}/vcpkg.exe install `
54             --clean-after-build `
55             $packages
57       - name: Install boost
58         run: |
59           aria2c `
60             "https://boostorg.jfrog.io/artifactory/main/release/1.83.0/source/boost_1_83_0.7z" `
61             -d "${{ runner.temp }}" `
62             -o "boost.7z"
63           7z x "${{ runner.temp }}/boost.7z" -o"${{ github.workspace }}/.."
64           move "${{ github.workspace }}/../boost_*" "${{ env.boost_path }}"
66       - name: Install Qt
67         uses: jurplel/install-qt-action@v3
68         with:
69           version: "6.5.2"
70           archives: qtbase qtsvg qttools
72       - name: Install libtorrent
73         run: |
74           git clone `
75             --branch v${{ matrix.libt_version }} `
76             --depth 1 `
77             --recurse-submodules `
78             https://github.com/arvidn/libtorrent.git
79           cd libtorrent
80           cmake `
81             -B build `
82             -G "Ninja" `
83             -DCMAKE_BUILD_TYPE=RelWithDebInfo `
84             -DCMAKE_CXX_FLAGS=/guard:cf `
85             -DCMAKE_EXPORT_COMPILE_COMMANDS=ON `
86             -DCMAKE_INSTALL_PREFIX="${{ env.libtorrent_path }}" `
87             -DCMAKE_TOOLCHAIN_FILE="${{ env.RUNVCPKG_VCPKG_ROOT }}/scripts/buildsystems/vcpkg.cmake" `
88             -DBOOST_ROOT="${{ env.boost_path }}" `
89             -DBUILD_SHARED_LIBS=OFF `
90             -Ddeprecated-functions=OFF `
91             -Dstatic_runtime=OFF `
92             -DVCPKG_TARGET_TRIPLET=x64-windows-static-release
93           cmake --build build
94           cmake --install build
96       - name: Build qBittorrent
97         run: |
98           cmake `
99             -B build `
100             -G "Ninja" `
101             -DCMAKE_BUILD_TYPE=RelWithDebInfo `
102             -DCMAKE_CXX_FLAGS="/WX" `
103             -DCMAKE_EXPORT_COMPILE_COMMANDS=ON `
104             -DCMAKE_TOOLCHAIN_FILE="${{ env.RUNVCPKG_VCPKG_ROOT }}/scripts/buildsystems/vcpkg.cmake" `
105             -DBOOST_ROOT="${{ env.boost_path }}" `
106             -DLibtorrentRasterbar_DIR="${{ env.libtorrent_path }}/lib/cmake/LibtorrentRasterbar" `
107             -DMSVC_RUNTIME_DYNAMIC=ON `
108             -DTESTING=ON `
109             -DVCPKG_TARGET_TRIPLET=x64-windows-static-release `
110             -DVERBOSE_CONFIGURE=ON `
111             --graphviz=build/target_graph.dot
112           cmake --build build --target qbt_update_translations
113           cmake --build build
114           cmake --build build --target check
116       - name: Prepare build artifacts
117         run: |
118           mkdir upload
119           copy build/qbittorrent.exe upload
120           copy build/qbittorrent.pdb upload
121           copy dist/windows/qt.conf upload
122           # runtimes
123           copy "${{ env.Qt6_DIR }}/bin/Qt6Core.dll" upload
124           copy "${{ env.Qt6_DIR }}/bin/Qt6Gui.dll" upload
125           copy "${{ env.Qt6_DIR }}/bin/Qt6Network.dll" upload
126           copy "${{ env.Qt6_DIR }}/bin/Qt6Sql.dll" upload
127           copy "${{ env.Qt6_DIR }}/bin/Qt6Svg.dll" upload
128           copy "${{ env.Qt6_DIR }}/bin/Qt6Widgets.dll" upload
129           copy "${{ env.Qt6_DIR }}/bin/Qt6Xml.dll" upload
130           mkdir upload/plugins/iconengines
131           copy "${{ env.Qt6_DIR }}/plugins/iconengines/qsvgicon.dll" upload/plugins/iconengines
132           mkdir upload/plugins/imageformats
133           copy "${{ env.Qt6_DIR }}/plugins/imageformats/qico.dll" upload/plugins/imageformats
134           copy "${{ env.Qt6_DIR }}/plugins/imageformats/qsvg.dll" upload/plugins/imageformats
135           mkdir upload/plugins/platforms
136           copy "${{ env.Qt6_DIR }}/plugins/platforms/qwindows.dll" upload/plugins/platforms
137           mkdir upload/plugins/sqldrivers
138           copy "${{ env.Qt6_DIR }}/plugins/sqldrivers/qsqlite.dll" upload/plugins/sqldrivers
139           mkdir upload/plugins/styles
140           copy "${{ env.Qt6_DIR }}/plugins/styles/qwindowsvistastyle.dll" upload/plugins/styles
141           mkdir upload/plugins/tls
142           copy "${{ env.Qt6_DIR }}/plugins/tls/qschannelbackend.dll" upload/plugins/tls
143           # cmake additionals
144           mkdir upload/cmake
145           copy build/compile_commands.json upload/cmake
146           copy build/target_graph.dot upload/cmake
147           mkdir upload/cmake/libtorrent
148           copy libtorrent/build/compile_commands.json upload/cmake/libtorrent
150       - name: Upload build artifacts
151         uses: actions/upload-artifact@v3
152         with:
153           name: qBittorrent-CI_Windows-x64_libtorrent-${{ matrix.libt_version }}
154           path: upload