Don't stuck loading on mismatching info-hashes in resume data
[qBittorrent.git] / .github / workflows / ci_windows.yaml
blob17af1e6127f2981d687131decad5dc6612267114
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"
25       vcpkg_path: "c:/vcpkg"
27     steps:
28       - name: Checkout repository
29         uses: actions/checkout@v4
31       - name: Setup devcmd
32         uses: ilammy/msvc-dev-cmd@v1
34       - name: Install build tools
35         run: |
36           if ((Get-Command "ninja.exe" -ErrorAction SilentlyContinue) -eq $null)
37           {
38              choco install ninja
39           }
40           where.exe ninja
41           ninja --version
43       # https://learn.microsoft.com/en-us/vcpkg/users/binarycaching#gha
44       - name: Set variables for vcpkg
45         uses: actions/github-script@v7
46         with:
47           script: |
48             core.exportVariable('ACTIONS_CACHE_URL', (process.env.ACTIONS_CACHE_URL || ''));
49             core.exportVariable('ACTIONS_RUNTIME_TOKEN', (process.env.ACTIONS_RUNTIME_TOKEN || ''));
51       - name: Install dependencies with vcpkg
52         run: |
53           # create our own triplet
54           New-Item `
55             -Force `
56             -ItemType File `
57             -Path "${{ env.vcpkg_path }}/triplets_overlay/x64-windows-static-md-release.cmake"
58           Add-Content `
59             -Path "${{ env.vcpkg_path }}/triplets_overlay/x64-windows-static-md-release.cmake" `
60             -Value @("set(VCPKG_TARGET_ARCHITECTURE x64)",
61               "set(VCPKG_LIBRARY_LINKAGE static)",
62               "set(VCPKG_CRT_LINKAGE dynamic)",
63               "set(VCPKG_BUILD_TYPE release)",
64               "set(VCPKG_C_FLAGS /guard:cf)",
65               "set(VCPKG_CXX_FLAGS /guard:cf)",
66               "set(VCPKG_LINKER_FLAGS /guard:cf)")
67           # clear buildtrees after each package installation to reduce disk space requirements
68           $packages = `
69             "openssl:x64-windows-static-md-release",
70             "zlib:x64-windows-static-md-release"
71           ${{ env.vcpkg_path }}/vcpkg.exe upgrade `
72             --no-dry-run `
73             --overlay-triplets="${{ env.vcpkg_path }}/triplets_overlay"
74           ${{ env.vcpkg_path }}/vcpkg.exe install `
75             --binarysource="clear;x-gha,readwrite" `
76             --clean-after-build `
77             --overlay-triplets="${{ env.vcpkg_path }}/triplets_overlay" `
78             $packages
80       - name: Install boost
81         run: |
82           $boost_url="https://boostorg.jfrog.io/artifactory/main/release/1.83.0/source/boost_1_83_0.tar.gz"
83           $boost_url2="https://sourceforge.net/projects/boost/files/boost/1.83.0/boost_1_83_0.tar.gz"
84           curl -L -o "${{ runner.temp }}/boost.tar.gz" "$boost_url"
85           tar -xf "${{ runner.temp }}/boost.tar.gz" -C "${{ github.workspace }}/.."
86           if ($LastExitCode -ne 0)
87           {
88             curl -L -o "${{ runner.temp }}/boost.tar.gz" "$boost_url2"
89             tar -xf "${{ runner.temp }}/boost.tar.gz" -C "${{ github.workspace }}/.."
90           }
91           move "${{ github.workspace }}/../boost_*" "${{ env.boost_path }}"
93       - name: Install Qt
94         uses: jurplel/install-qt-action@v3
95         with:
96           version: "6.5.2"
97           archives: qtbase qtsvg qttools
98           cache: true
100       - name: Install libtorrent
101         run: |
102           git clone `
103             --branch v${{ matrix.libt_version }} `
104             --depth 1 `
105             --recurse-submodules `
106             https://github.com/arvidn/libtorrent.git `
107             ${{ env.libtorrent_path }}
108           cd ${{ env.libtorrent_path }}
109           $env:CXXFLAGS+=" /guard:cf"
110           $env:LDFLAGS+=" /guard:cf"
111           cmake `
112             -B build `
113             -G "Ninja" `
114             -DCMAKE_BUILD_TYPE=RelWithDebInfo `
115             -DCMAKE_EXPORT_COMPILE_COMMANDS=ON `
116             -DCMAKE_INSTALL_PREFIX="${{ env.libtorrent_path }}/install" `
117             -DCMAKE_TOOLCHAIN_FILE="${{ env.vcpkg_path }}/scripts/buildsystems/vcpkg.cmake" `
118             -DBOOST_ROOT="${{ env.boost_path }}" `
119             -DBUILD_SHARED_LIBS=OFF `
120             -Ddeprecated-functions=OFF `
121             -Dstatic_runtime=OFF `
122             -DVCPKG_TARGET_TRIPLET=x64-windows-static-md-release
123           cmake --build build
124           cmake --install build
126       - name: Build qBittorrent
127         run: |
128           $env:CXXFLAGS+=" /WX"
129           cmake `
130             -B build `
131             -G "Ninja" `
132             -DCMAKE_BUILD_TYPE=RelWithDebInfo `
133             -DCMAKE_EXPORT_COMPILE_COMMANDS=ON `
134             -DCMAKE_TOOLCHAIN_FILE="${{ env.vcpkg_path }}/scripts/buildsystems/vcpkg.cmake" `
135             -DBOOST_ROOT="${{ env.boost_path }}" `
136             -DLibtorrentRasterbar_DIR="${{ env.libtorrent_path }}/install/lib/cmake/LibtorrentRasterbar" `
137             -DMSVC_RUNTIME_DYNAMIC=ON `
138             -DTESTING=ON `
139             -DVCPKG_TARGET_TRIPLET=x64-windows-static-md-release `
140             -DVERBOSE_CONFIGURE=ON `
141             --graphviz=build/target_graph.dot
142           cmake --build build --target qbt_update_translations
143           cmake --build build
144           cmake --build build --target check
146       - name: Prepare build artifacts
147         run: |
148           mkdir upload
149           mkdir upload/qBittorrent
150           copy build/qbittorrent.exe upload/qBittorrent
151           copy build/qbittorrent.pdb upload/qBittorrent
152           copy dist/windows/qt.conf upload/qBittorrent
153           # runtimes
154           copy "${{ env.Qt6_DIR }}/bin/Qt6Core.dll" upload/qBittorrent
155           copy "${{ env.Qt6_DIR }}/bin/Qt6Gui.dll" upload/qBittorrent
156           copy "${{ env.Qt6_DIR }}/bin/Qt6Network.dll" upload/qBittorrent
157           copy "${{ env.Qt6_DIR }}/bin/Qt6Sql.dll" upload/qBittorrent
158           copy "${{ env.Qt6_DIR }}/bin/Qt6Svg.dll" upload/qBittorrent
159           copy "${{ env.Qt6_DIR }}/bin/Qt6Widgets.dll" upload/qBittorrent
160           copy "${{ env.Qt6_DIR }}/bin/Qt6Xml.dll" upload/qBittorrent
161           mkdir upload/qBittorrent/plugins/iconengines
162           copy "${{ env.Qt6_DIR }}/plugins/iconengines/qsvgicon.dll" upload/qBittorrent/plugins/iconengines
163           mkdir upload/qBittorrent/plugins/imageformats
164           copy "${{ env.Qt6_DIR }}/plugins/imageformats/qico.dll" upload/qBittorrent/plugins/imageformats
165           copy "${{ env.Qt6_DIR }}/plugins/imageformats/qsvg.dll" upload/qBittorrent/plugins/imageformats
166           mkdir upload/qBittorrent/plugins/platforms
167           copy "${{ env.Qt6_DIR }}/plugins/platforms/qwindows.dll" upload/qBittorrent/plugins/platforms
168           mkdir upload/qBittorrent/plugins/sqldrivers
169           copy "${{ env.Qt6_DIR }}/plugins/sqldrivers/qsqlite.dll" upload/qBittorrent/plugins/sqldrivers
170           mkdir upload/qBittorrent/plugins/styles
171           copy "${{ env.Qt6_DIR }}/plugins/styles/qwindowsvistastyle.dll" upload/qBittorrent/plugins/styles
172           mkdir upload/qBittorrent/plugins/tls
173           copy "${{ env.Qt6_DIR }}/plugins/tls/qschannelbackend.dll" upload/qBittorrent/plugins/tls
174           # cmake additionals
175           mkdir upload/cmake
176           copy build/compile_commands.json upload/cmake
177           copy build/target_graph.dot upload/cmake
178           mkdir upload/cmake/libtorrent
179           copy ${{ env.libtorrent_path }}/build/compile_commands.json upload/cmake/libtorrent
181       - name: Upload build artifacts
182         uses: actions/upload-artifact@v4
183         with:
184           name: qBittorrent-CI_Windows-x64_libtorrent-${{ matrix.libt_version }}
185           path: upload
187       - name: Create installer
188         run: |
189           7z x -o"dist/windows/" "dist/windows/NSISPlugins.zip"
190           makensis /DQBT_DIST_DIR="../../upload/qBittorrent" dist/windows/qbittorrent.nsi
192       - name: Upload installer
193         uses: actions/upload-artifact@v4
194         with:
195           name: qBittorrent-CI_Windows-x64_libtorrent-${{ matrix.libt_version }}-setup
196           path: dist/windows/qbittorrent_*_setup.exe